[Python-checkins] r54999 - sandbox/trunk/2to3/fixes/fix_next.py

guido.van.rossum python-checkins at python.org
Fri Apr 27 18:20:40 CEST 2007


Author: guido.van.rossum
Date: Fri Apr 27 18:20:39 2007
New Revision: 54999

Modified:
   sandbox/trunk/2to3/fixes/fix_next.py
Log:
Add clone() method to DelayedStrNode class; it may be called.


Modified: sandbox/trunk/2to3/fixes/fix_next.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_next.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_next.py	Fri Apr 27 18:20:39 2007
@@ -14,14 +14,16 @@
 
 bind_warning = "Calls to builtin next() possibly shadowed by global binding"
 
+
 class DelayedStrNode(object):
+
     def __init__(self, type, base):
         self.parent = None
         self.shadowed_next = False
         self.base = base
         self.type = type
         self.value = ""
-        
+
     def __str__(self):
         b = "".join([str(n) for n in self.base])
         if self.shadowed_next:
@@ -29,6 +31,13 @@
         else:
             return "next(%s)" % b
 
+    def clone(self):
+        node = DelayedStrNode(self.type, self.base)
+        node.shadowed_next = self.shadowed_next
+        node.value = self.value
+        return node
+
+
 class FixNext(basefix.BaseFix):
     PATTERN = """
     power< base=any+ trailer< '.' 'next' > trailer< '(' ')' > >


More information about the Python-checkins mailing list