Skip to content

Commit

Permalink
temporary identifiers are prefixed with "t_" now and the _node_setup_…
Browse files Browse the repository at this point in the history
…finished hack went away

--HG--
branch : trunk
  • Loading branch information
mitsuhiko committed May 19, 2008
1 parent bbbe062 commit 8a1d27f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion jinja2/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def __init__(self, environment, name, filename, stream=None):
def temporary_identifier(self):
"""Get a new unique identifier."""
self._last_identifier += 1
return 't%d' % self._last_identifier
return 't_%d' % self._last_identifier

def buffer(self, frame):
"""Enable buffering for the frame from that point onwards."""
Expand Down
5 changes: 1 addition & 4 deletions jinja2/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ def __new__(cls, lineno, type, value):
return tuple.__new__(cls, (lineno, intern(str(type)), value))

def __str__(self):
from jinja.lexer import keywords, reverse_operators
if self.type in keywords:
return self.type
elif self.type in reverse_operators:
if self.type in reverse_operators:
return reverse_operators[self.type]
elif self.type is 'name':
return self.value
Expand Down
12 changes: 4 additions & 8 deletions jinja2/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
}


# if this is `True` no new Node classes can be created.
_node_setup_finished = False


class Impossible(Exception):
"""Raised if the node could not perform a requested action."""

Expand All @@ -62,8 +58,6 @@ class NodeType(type):
automatically forwarded to the child."""

def __new__(cls, name, bases, d):
if __debug__ and _node_setup_finished:
raise TypeError('Can\'t create custom node types.')
for attr in 'fields', 'attributes':
storage = []
storage.extend(getattr(bases[0], attr, ()))
Expand Down Expand Up @@ -808,5 +802,7 @@ class Break(Stmt):
"""Break a loop."""


# and close down
_node_setup_finished = True
# make sure nobody creates custom nodes
def _failing_new(*args, **kwargs):
raise TypeError('can\'t create custom node types')
NodeType.__new__ = staticmethod(_failing_new); del _failing_new

0 comments on commit 8a1d27f

Please sign in to comment.