[Python-checkins] r67679 - in sandbox/trunk/2to3/lib2to3: fixes/fix_long.py tests/test_fixers.py

armin.ronacher python-checkins at python.org
Tue Dec 9 07:54:04 CET 2008


Author: armin.ronacher
Date: Tue Dec  9 07:54:03 2008
New Revision: 67679

Log:
Removed redudant code from the 2to3 long fixer.  This fixes #4590.



Modified:
   sandbox/trunk/2to3/lib2to3/fixes/fix_long.py
   sandbox/trunk/2to3/lib2to3/tests/test_fixers.py

Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_long.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_long.py	(original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_long.py	Tue Dec  9 07:54:03 2008
@@ -2,8 +2,6 @@
 # Licensed to PSF under a Contributor Agreement.
 
 """Fixer that turns 'long' into 'int' everywhere.
-
-This also strips the trailing 'L' or 'l' from long loterals.
 """
 
 # Local imports
@@ -14,22 +12,13 @@
 
 class FixLong(fixer_base.BaseFix):
 
-    PATTERN = """
-    (long_type = 'long' | number = NUMBER)
-    """
+    PATTERN = "'long'"
 
     static_long = Name("long")
     static_int = Name("int")
 
     def transform(self, node, results):
-        long_type = results.get("long_type")
-        number = results.get("number")
-        new = None
-        if long_type:
-            assert node == self.static_long, node
-            new = self.static_int.clone()
-        if number and node.value[-1] in ("l", "L"):
-            new = Number(node.value[:-1])
-        if new is not None:
-            new.set_prefix(node.get_prefix())
-            return new
+        assert node == self.static_long, node
+        new = self.static_int.clone()
+        new.set_prefix(node.get_prefix())
+        return new

Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py	(original)
+++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py	Tue Dec  9 07:54:03 2008
@@ -1071,28 +1071,6 @@
         a = """z = type(x) in (int, int)"""
         self.check(b, a)
 
-    def test_4(self):
-        b = """a = 12L"""
-        a = """a = 12"""
-        self.check(b, a)
-
-    def test_5(self):
-        b = """b = 0x12l"""
-        a = """b = 0x12"""
-        self.check(b, a)
-
-    def test_unchanged_1(self):
-        s = """a = 12"""
-        self.unchanged(s)
-
-    def test_unchanged_2(self):
-        s = """b = 0x12"""
-        self.unchanged(s)
-
-    def test_unchanged_3(self):
-        s = """c = 3.14"""
-        self.unchanged(s)
-
     def test_prefix_preservation(self):
         b = """x =   long(  x  )"""
         a = """x =   int(  x  )"""


More information about the Python-checkins mailing list