[pypy-commit] pypy py3k: don't parse '0L' anymore

amauryfa noreply at buildbot.pypy.org
Sat Jan 14 21:48:38 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r51327:40196a1cc504
Date: 2011-12-27 00:03 +0100
http://bitbucket.org/pypy/pypy/changeset/40196a1cc504/

Log:	don't parse '0L' anymore

diff --git a/pypy/interpreter/pyparser/genpytokenize.py b/pypy/interpreter/pyparser/genpytokenize.py
--- a/pypy/interpreter/pyparser/genpytokenize.py
+++ b/pypy/interpreter/pyparser/genpytokenize.py
@@ -60,25 +60,21 @@
                       newArcPair(states, "0"),
                       groupStr(states, "xX"),
                       atleastonce(states,
-                                  groupStr(states, "0123456789abcdefABCDEF")),
-                      maybe(states, groupStr(states, "lL")))
+                                  groupStr(states, "0123456789abcdefABCDEF")))
     octNumber = chain(states,
                       newArcPair(states, "0"),
                       maybe(states,
                             chain(states,
                                   groupStr(states, "oO"),
                                   groupStr(states, "01234567"))),
-                      any(states, groupStr(states, "01234567")),
-                      maybe(states, groupStr(states, "lL")))
+                      any(states, groupStr(states, "01234567")))
     binNumber = chain(states,
                       newArcPair(states, "0"),
                       groupStr(states, "bB"),
-                      atleastonce(states, groupStr(states, "01")),
-                      maybe(states, groupStr(states, "lL")))
+                      atleastonce(states, groupStr(states, "01")))
     decNumber = chain(states,
                       groupStr(states, "123456789"),
-                      any(states, makeDigits()),
-                      maybe(states, groupStr(states, "lL")))
+                      any(states, makeDigits()))
     intNumber = group(states, hexNumber, octNumber, binNumber, decNumber)
     # ____________________________________________________________
     # Exponents
diff --git a/pypy/interpreter/pyparser/pytokenize.py b/pypy/interpreter/pyparser/pytokenize.py
--- a/pypy/interpreter/pyparser/pytokenize.py
+++ b/pypy/interpreter/pyparser/pytokenize.py
@@ -113,15 +113,14 @@
     {'.': 24, '0': 21, '1': 21, '2': 21,
      '3': 21, '4': 21, '5': 21, '6': 21,
      '7': 21, '8': 23, '9': 23, 'B': 22,
-     'E': 25, 'J': 13, 'L': 13, 'O': 20,
-     'X': 19, 'b': 22, 'e': 25, 'j': 13,
-     'l': 13, 'o': 20, 'x': 19},
+     'E': 25, 'J': 13, 'O': 20, 'X': 19,
+     'b': 22, 'e': 25, 'j': 13, 'o': 20,
+     'x': 19},
     # 5
     {'.': 24, '0': 5, '1': 5, '2': 5,
      '3': 5, '4': 5, '5': 5, '6': 5,
      '7': 5, '8': 5, '9': 5, 'E': 25,
-     'J': 13, 'L': 13, 'e': 25, 'j': 13,
-     'l': 13},
+     'J': 13, 'e': 25, 'j': 13},
     # 6
     {'0': 26, '1': 26, '2': 26, '3': 26,
      '4': 26, '5': 26, '6': 26, '7': 26,
@@ -166,8 +165,7 @@
     {'.': 24, '0': 21, '1': 21, '2': 21,
      '3': 21, '4': 21, '5': 21, '6': 21,
      '7': 21, '8': 23, '9': 23, 'E': 25,
-     'J': 13, 'L': 13, 'e': 25, 'j': 13,
-     'l': 13},
+     'J': 13, 'e': 25, 'j': 13},
     # 22
     {'0': 36, '1': 36},
     # 23
@@ -210,14 +208,13 @@
      '4': 34, '5': 34, '6': 34, '7': 34,
      '8': 34, '9': 34, 'A': 34, 'B': 34,
      'C': 34, 'D': 34, 'E': 34, 'F': 34,
-     'L': 13, 'a': 34, 'b': 34, 'c': 34,
-     'd': 34, 'e': 34, 'f': 34, 'l': 13},
+     'a': 34, 'b': 34, 'c': 34, 'd': 34,
+     'e': 34, 'f': 34},
     # 35
     {'0': 35, '1': 35, '2': 35, '3': 35,
-     '4': 35, '5': 35, '6': 35, '7': 35,
-     'L': 13, 'l': 13},
+     '4': 35, '5': 35, '6': 35, '7': 35},
     # 36
-    {'0': 36, '1': 36, 'L': 13, 'l': 13},
+    {'0': 36, '1': 36},
     # 37
     {'+': 42, '-': 42, '0': 43, '1': 43,
      '2': 43, '3': 43, '4': 43, '5': 43,
diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -351,8 +351,8 @@
         assert pow(2, -10) == 1/1024.
 
     def test_int_w_long_arg(self):
-        assert int(10000000000) == 10000000000L
-        assert int("10000000000") == 10000000000l
+        assert int(10000000000) == 10000000000
+        assert int("10000000000") == 10000000000
         raises(ValueError, int, "10000000000JUNK")
         raises(ValueError, int, "10000000000JUNK", 10)
 
@@ -362,7 +362,7 @@
             pass
         assert j(100) == 100
         assert isinstance(j(100),j)
-        assert j(100L) == 100
+        assert j(100) == 100
         assert j("100") == 100
         assert j("100",2) == 4
         assert isinstance(j("100",2),j)
@@ -408,14 +408,14 @@
                 return '<instance of j>'
         class subint(int):
             pass
-        value = 42L
+        value = 42
         assert int(j()) == 42
-        value = 4200000000000000000000000000000000L
-        assert int(j()) == 4200000000000000000000000000000000L
+        value = 4200000000000000000000000000000000
+        assert int(j()) == 4200000000000000000000000000000000
         value = subint(42)
         assert int(j()) == 42 and type(int(j())) is subint
-        value = subint(4200000000000000000000000000000000L)
-        assert (int(j()) == 4200000000000000000000000000000000L
+        value = subint(4200000000000000000000000000000000)
+        assert (int(j()) == 4200000000000000000000000000000000
                 and type(int(j())) is subint)
         value = 42.0
         raises(TypeError, int, j())
diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -43,44 +43,44 @@
 
     def test_trunc(self):
         import math
-        assert math.trunc(1L) == 1L
-        assert math.trunc(-1L) == -1L
+        assert math.trunc(1) == 1
+        assert math.trunc(-1) == -1
 
     def test_add(self):
-        x = 123L
-        assert int(x + 12443L) == 123 + 12443
+        x = 123
+        assert int(x + 12443) == 123 + 12443
         x = -20
-        assert x + 2 + 3L + True == -14L
+        assert x + 2 + 3 + True == -14
 
     def test_sub(self):
-        x = 58543L
-        assert int(x - 12332L) == 58543 - 12332
-        x = 237123838281233L
-        assert x * 12 == x * 12L
+        x = 58543
+        assert int(x - 12332) == 58543 - 12332
+        x = 237123838281233
+        assert x * 12 == x * 12
 
     def test_mul(self):
-        x = 363L
+        x = 363
         assert x * 2 ** 40 == x << 40
 
     def test_truediv(self):
-        a = 31415926L / 10000000L
+        a = 31415926 / 10000000
         assert a == 3.1415926
 
     def test_floordiv(self):
-        x = 31415926L
-        a = x // 10000000L
-        assert a == 3L
+        x = 31415926
+        a = x // 10000000
+        assert a == 3
 
     def test_numerator_denominator(self):
-        assert (1L).numerator == 1L
-        assert (1L).denominator == 1L
-        assert (42L).numerator == 42L
-        assert (42L).denominator == 1L
+        assert (1).numerator == 1
+        assert (1).denominator == 1
+        assert (42).numerator == 42
+        assert (42).denominator == 1
 
     def test_compare(self):
         Z = 0
-        ZL = 0L
-        for BIG in (1L, 1L << 62, 1L << 9999):
+        ZL = 0
+        for BIG in (1, 1 << 62, 1 << 9999):
             assert Z == ZL
             assert not (Z != ZL)
             assert ZL == Z
@@ -157,7 +157,7 @@
     def test_conversion(self):
         class long2(int):
             pass
-        x = 1L
+        x = 1
         x = long2(x<<100)
         y = int(x)
         assert type(y) == int
@@ -173,12 +173,12 @@
         assert type(long2(5) // 1) is int
 
     def test_pow(self):
-        x = 0L
-        assert pow(x, 0L, 1L) == 0L
+        x = 0
+        assert pow(x, 0, 1) == 0
 
     def test_getnewargs(self):
-        assert  0L .__getnewargs__() == (0L,)
-        assert  (-1L) .__getnewargs__() == (-1L,)
+        assert  0 .__getnewargs__() == (0,)
+        assert  (-1) .__getnewargs__() == (-1,)
 
     def test_divmod(self):
         def check_division(x, y):
@@ -192,8 +192,8 @@
                 assert 0 <= r < y
             else:
                 assert y < r <= 0
-        for x in [-1L, 0L, 1L, 2L ** 100 - 1, -2L ** 100 - 1]:
-            for y in [-105566530L, -1L, 1L, 1034522340L]:
+        for x in [-1, 0, 1, 2 ** 100 - 1, -2 ** 100 - 1]:
+            for y in [-105566530, -1, 1, 1034522340]:
                 print("checking division for %s, %s" % (x, y))
                 check_division(x, y)
         # special case from python tests:
@@ -203,10 +203,10 @@
         x >>= s1*16
         y = 10953035502453784575
         y >>= s2*16
-        x = 0x3FE0003FFFFC0001FFFL
-        y = 0x9800FFC1L
+        x = 0x3FE0003FFFFC0001FFF
+        y = 0x9800FFC1
         check_division(x, y)
-        raises(ZeroDivisionError, "x // 0L")
+        raises(ZeroDivisionError, "x // 0")
 
     def test_format(self):
         assert repr(12345678901234567890) == '12345678901234567890'
@@ -215,31 +215,31 @@
         assert oct(01234567012345670) == '01234567012345670'
 
     def test_bits(self):
-        x = 0xAAAAAAAAL
-        assert x | 0x55555555L == 0xFFFFFFFFL
-        assert x & 0x55555555L == 0x00000000L
-        assert x ^ 0x55555555L == 0xFFFFFFFFL
-        assert -x | 0x55555555L == -0xAAAAAAA9L
-        assert x | 0x555555555L == 0x5FFFFFFFFL
-        assert x & 0x555555555L == 0x000000000L
-        assert x ^ 0x555555555L == 0x5FFFFFFFFL
+        x = 0xAAAAAAAA
+        assert x | 0x55555555 == 0xFFFFFFFF
+        assert x & 0x55555555 == 0x00000000
+        assert x ^ 0x55555555 == 0xFFFFFFFF
+        assert -x | 0x55555555 == -0xAAAAAAA9
+        assert x | 0x555555555 == 0x5FFFFFFFF
+        assert x & 0x555555555 == 0x000000000
+        assert x ^ 0x555555555 == 0x5FFFFFFFF
 
     def test_hash(self):
         # ints have the same hash as equal longs
         for i in range(-4, 14):
             assert hash(i) == hash(int(i))
         # might check too much -- it's ok to change the hashing algorithm
-        assert hash(123456789L) == 123456789
-        assert hash(1234567890123456789L) in (
+        assert hash(123456789) == 123456789
+        assert hash(1234567890123456789) in (
             -1895067127,            # with 32-bit platforms
             1234567890123456789)    # with 64-bit platforms
 
     def test_math_log(self):
         import math
-        raises(ValueError, math.log, 0L) 
-        raises(ValueError, math.log, -1L) 
-        raises(ValueError, math.log, -2L) 
-        raises(ValueError, math.log, -(1L << 10000))
+        raises(ValueError, math.log, 0) 
+        raises(ValueError, math.log, -1) 
+        raises(ValueError, math.log, -2) 
+        raises(ValueError, math.log, -(1 << 10000))
         #raises(ValueError, math.log, 0) 
         raises(ValueError, math.log, -1) 
         raises(ValueError, math.log, -2) 
@@ -252,11 +252,11 @@
 
     def test_huge_longs(self):
         import operator
-        x = 1L
-        huge = x << 40000L
+        x = 1
+        huge = x << 40000
         raises(OverflowError, float, huge)
         raises(OverflowError, operator.truediv, huge, 3)
-        raises(OverflowError, operator.truediv, huge, 3L)
+        raises(OverflowError, operator.truediv, huge, 3)
 
     def test_just_trunc(self):
         class myint(object):
@@ -267,17 +267,17 @@
     def test_override___int__(self):
         class myint(int):
             def __int__(self):
-                return 42L
-        assert int(myint(21)) == 42L
+                return 42
+        assert int(myint(21)) == 42
         class myotherint(int):
             pass
-        assert int(myotherint(21)) == 21L
+        assert int(myotherint(21)) == 21
 
     def test___int__(self):
         class A(object):
             def __int__(self):
                 return 42
-        assert int(A()) == 42L
+        assert int(A()) == 42
         # but!: (blame CPython 2.7)
         class Integral(object):
             def __int__(self):
@@ -288,8 +288,8 @@
         assert int(TruncReturnsNonInt()) == 42
 
     def test_conjugate(self):
-        assert (7L).conjugate() == 7L
-        assert (-7L).conjugate() == -7L
+        assert (7).conjugate() == 7
+        assert (-7).conjugate() == -7
 
         class L(int):
             pass
@@ -299,10 +299,10 @@
         class L(int):
             def __pos__(self):
                 return 43
-        assert L(7).conjugate() == 7L
+        assert L(7).conjugate() == 7
 
     def test_bit_length(self):
-        assert 8L.bit_length() == 4
+        assert (8).bit_length() == 4
         assert (-1<<40).bit_length() == 41
         assert ((2**31)-1).bit_length() == 31
 
@@ -311,8 +311,8 @@
         assert int.from_bytes(b'\x01\x01', 'little') == 257
 
     def test_negative_zero(self):
-        x = eval("-0L")
-        assert x == 0L
+        x = eval("-0")
+        assert x == 0
 
     def test_long_real(self):
         class A(int): pass


More information about the pypy-commit mailing list