Created
June 18, 2012 19:46
-
-
Save georgexsh/2950320 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 9652cdeba438 mako/pyparser.py | |
--- a/mako/pyparser.py Wed May 16 10:38:44 2012 -0400 | |
+++ b/mako/pyparser.py Tue Jun 19 03:44:07 2012 +0800 | |
@@ -66,7 +66,7 @@ | |
def __init__(self, listener, **exception_kwargs): | |
self.in_function = False | |
self.in_assign_targets = False | |
- self.local_ident_stack = {} | |
+ self.local_ident_stack = set() | |
self.listener = listener | |
self.exception_kwargs = exception_kwargs | |
@@ -118,23 +118,17 @@ | |
# argument names in each function header so they arent | |
# counted as "undeclared" | |
- saved = {} | |
inf = self.in_function | |
self.in_function = True | |
for arg in node.args.args: | |
- if arg_id(arg) in self.local_ident_stack: | |
- saved[arg_id(arg)] = True | |
- else: | |
- self.local_ident_stack[arg_id(arg)] = True | |
+ self.local_ident_stack.add(arg_id(arg)) | |
if islambda: | |
self.visit(node.body) | |
else: | |
for n in node.body: | |
self.visit(n) | |
self.in_function = inf | |
- for arg in node.args.args: | |
- if arg_id(arg) not in saved: | |
- del self.local_ident_stack[arg_id(arg)] | |
+ self.local_ident_stack = set() | |
def visit_For(self, node): | |
@@ -150,9 +144,11 @@ | |
def visit_Name(self, node): | |
if isinstance(node.ctx, _ast.Store): | |
self._add_declared(node.id) | |
- if node.id not in reserved and node.id \ | |
- not in self.listener.declared_identifiers and node.id \ | |
- not in self.local_ident_stack: | |
+ if node.id not in self.local_ident_stack: | |
+ self.local_ident_stack.add(node.id) | |
+ if node.id not in reserved and \ | |
+ node.id not in self.listener.declared_identifiers and \ | |
+ node.id not in self.local_ident_stack: | |
self.listener.undeclared_identifiers.add(node.id) | |
def visit_Import(self, node): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment