Removed a few stdlib dependencies. This is the first step for IronPython support, the second one being a new lexer.
--HG--
branch : trunk
diff --git a/jinja2/compiler.py b/jinja2/compiler.py
index f1e182b..fab6ea0 100644
--- a/jinja2/compiler.py
+++ b/jinja2/compiler.py
@@ -8,14 +8,12 @@
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""
-from copy import copy
-from keyword import iskeyword
from cStringIO import StringIO
from itertools import chain
from jinja2 import nodes
from jinja2.visitor import NodeVisitor, NodeTransformer
from jinja2.exceptions import TemplateAssertionError
-from jinja2.utils import Markup, concat, escape
+from jinja2.utils import Markup, concat, escape, is_python_keyword
operators = {
@@ -164,8 +162,10 @@
def copy(self):
"""Create a copy of the current one."""
- rv = copy(self)
- rv.identifiers = copy(self.identifiers)
+ rv = object.__new__(self.__class__)
+ rv.__dict__.update(self.__dict__)
+ rv.identifiers = object.__new__(self.identifiers.__class__)
+ rv.identifiers.__dict__.update(self.identifiers.__dict__)
return rv
def inspect(self, nodes, hard_scope=False):
@@ -186,10 +186,12 @@
standalone thing as it shares the resources with the frame it
was created of, but it's not a rootlevel frame any longer.
"""
- rv = copy(self)
+ rv = self.copy()
rv.rootlevel = False
return rv
+ __copy__ = copy
+
class VisitorExit(RuntimeError):
"""Exception used by the `UndeclaredNameVisitor` to signal a stop."""
@@ -449,7 +451,7 @@
# we have to make sure that no invalid call is created.
kwarg_workaround = False
for kwarg in chain((x.key for x in node.kwargs), extra_kwargs or ()):
- if iskeyword(kwarg):
+ if is_python_keyword(kwarg):
kwarg_workaround = True
break