[Python-checkins] r54769 - sandbox/trunk/2to3/fixes/fix_except.py

collin.winter python-checkins at python.org
Thu Apr 12 05:02:12 CEST 2007


Author: collin.winter
Date: Thu Apr 12 05:02:04 2007
New Revision: 54769
Modified:
 sandbox/trunk/2to3/fixes/fix_except.py
Log:
Refactor to use the Name() macro.
Modified: sandbox/trunk/2to3/fixes/fix_except.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_except.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_except.py	Thu Apr 12 05:02:04 2007
@@ -33,10 +33,6 @@
 if n.children[0].value == 'except':
 yield (n, nodes[i+2])
 
-### Common across all transforms
-as_leaf = pytree.Leaf(token.NAME, "as")
-as_leaf.set_prefix(" ")
-
 class FixExcept(basefix.BaseFix):
 
 PATTERN = """
@@ -55,7 +51,8 @@
 for except_clause, e_suite in find_excepts(try_cleanup):
 if len(except_clause.children) == 4:
 (E, comma, N) = except_clause.children[1:4]
- comma.replace(as_leaf.clone())
+ comma.replace(Name("as", prefix=" "))
+
 if N.type != token.NAME:
 # Generate a new N for the except clause
 new_N = Name(self.new_name(), prefix=" ")


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /