[Python-checkins] r66860 - sandbox/trunk/2to3/lib2to3/fixes/fix_next.py
benjamin.peterson
python-checkins at python.org
Wed Oct 8 23:05:07 CEST 2008
Author: benjamin.peterson
Date: Wed Oct 8 23:05:07 2008
New Revision: 66860
Log:
instead of abusing the pattern matcher, use start_tree to find a next binding
Modified:
sandbox/trunk/2to3/lib2to3/fixes/fix_next.py
Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_next.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_next.py (original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_next.py Wed Oct 8 23:05:07 2008
@@ -28,15 +28,19 @@
any* > >
|
global=global_stmt< 'global' any* 'next' any* >
- |
- mod=file_input< any+ >
"""
order = "pre" # Pre-order tree traversal
def start_tree(self, tree, filename):
super(FixNext, self).start_tree(tree, filename)
- self.shadowed_next = False
+
+ n = find_binding('next', tree)
+ if n:
+ self.warning(n, bind_warning)
+ self.shadowed_next = True
+ else:
+ self.shadowed_next = False
def transform(self, node, results):
assert results
@@ -69,11 +73,6 @@
elif "global" in results:
self.warning(node, bind_warning)
self.shadowed_next = True
- elif mod:
- n = find_binding('next', mod)
- if n:
- self.warning(n, bind_warning)
- self.shadowed_next = True
### The following functions help test if node is part of an assignment
More information about the Python-checkins
mailing list