diff genshi/template/eval.py @ 563:9d1c5c290254 trunk

Built-in Python constants (such as `None`) in expressions are used directly instead of being looked up from the context.
author cmlenz
date Fri, 13 Jul 2007 11:10:38 +0000
parents 4ed941aa0cbf
children aeb89e9730df
line wrap: on
line diff
--- a/genshi/template/eval.py
+++ b/genshi/template/eval.py
@@ -390,7 +390,7 @@
 
 BUILTINS = __builtin__.__dict__.copy()
 BUILTINS.update({'Markup': Markup, 'Undefined': Undefined})
-
+CONSTANTS = frozenset(['False', 'True', 'None', 'NotImplemented', 'Ellipsis'])
 
 class ASTTransformer(object):
     """General purpose base class for AST transformations.
@@ -654,7 +654,7 @@
     """
 
     def __init__(self):
-        self.locals = []
+        self.locals = [CONSTANTS, set()]
 
     def visitConst(self, node):
         if isinstance(node.value, str):
Copyright (C) 2012-2017 Edgewall Software