Skip to content
Myr

temporary identifiers are prefixed with "t_" now and the _node_setup_finished hack went away

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent bbbe062 · Browse files · 3 files+6 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+6 added−13 removed

  • other:+6 added−13 removed

3 files+6 added−13 removed

modified:jinja2/compiler.py+1 added-1 removed
353 unmodified lines
354355 def temporary_identifier(self):356 """Get a new unique identifier."""357 self._last_identifier += 1358 return 't%d' % self._last_identifier358 return 't_%d' % self._last_identifier359360 def buffer(self, frame):361 """Enable buffering for the frame from that point onwards."""362 frame.buffer = buf = self.temporary_identifier()
1014 unmodified lines
modified:jinja2/lexer.py+1 added-4 removed
90 unmodified lines
91 def __new__(cls, lineno, type, value):92 return tuple.__new__(cls, (lineno, intern(str(type)), value))9394 def __str__(self):95 from jinja.lexer import keywords, reverse_operators96 if self.type in keywords:97 return self.type98 elif self.type in reverse_operators:95 if self.type in reverse_operators:96 return reverse_operators[self.type]97 elif self.type is 'name':98 return self.value99 return self.type
458 unmodified lines
modified:jinja2/nodes.py+4 added-8 removed
46 unmodified lines
47 'notin': lambda a, b: a not in b48}495051# if this is `True` no new Node classes can be created.52_node_setup_finished = False535451class Impossible(Exception):52 """Raised if the node could not perform a requested action."""5354
2 unmodified lines
57 inheritance. fields and attributes from the parent class are58 automatically forwarded to the child."""5960 def __new__(cls, name, bases, d):65 if __debug__ and _node_setup_finished:66 raise TypeError('Can\'t create custom node types.')61 for attr in 'fields', 'attributes':62 storage = []63 storage.extend(getattr(bases[0], attr, ()))64 storage.extend(d.get(attr, ()))
736 unmodified lines
801class Break(Stmt):802 """Break a loop."""803804811# and close down812_node_setup_finished = True805# make sure nobody creates custom nodes806def _failing_new(*args, **kwargs):807 raise TypeError('can\'t create custom node types')808NodeType.__new__ = staticmethod(_failing_new); del _failing_new