Skip to content

Commit

Permalink
Rip out 'long' and 'L'-suffixed integer literals.
Browse files Browse the repository at this point in the history
(Rough first cut.)
  • Loading branch information
gvanrossum committed Jan 15, 2007
1 parent fc7bb8c commit e2a383d
Show file tree
Hide file tree
Showing 146 changed files with 1,443 additions and 1,474 deletions.
8 changes: 4 additions & 4 deletions Lib/BaseHTTPServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ def send_error(self, code, message=None):
"""

try:
short, long = self.responses[code]
shortmsg, longmsg = self.responses[code]
except KeyError:
short, long = '???', '???'
shortmsg, longmsg = '???', '???'
if message is None:
message = short
explain = long
message = shortmsg
explain = longmsg
self.log_error("code %d, message %s", code, message)
# using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201)
content = (self.error_message_format %
Expand Down
2 changes: 1 addition & 1 deletion Lib/UserString.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, seq):
def __str__(self): return str(self.data)
def __repr__(self): return repr(self.data)
def __int__(self): return int(self.data)
def __long__(self): return long(self.data)
def __long__(self): return int(self.data)
def __float__(self): return float(self.data)
def __complex__(self): return complex(self.data)
def __hash__(self): return hash(self.data)
Expand Down
8 changes: 4 additions & 4 deletions Lib/aifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
class Error(Exception):
pass

_AIFC_version = 0xA2805140L # Version 1 of AIFF-C
_AIFC_version = 0xA2805140 # Version 1 of AIFF-C

_skiplist = 'COMT', 'INST', 'MIDI', 'AESD', \
'APPL', 'NAME', 'AUTH', '(c) ', 'ANNO'
Expand Down Expand Up @@ -191,7 +191,7 @@ def _read_float(f): # 10 bytes
f = _HUGE_VAL
else:
expon = expon - 16383
f = (himant * 0x100000000L + lomant) * pow(2.0, expon - 63)
f = (himant * 0x100000000 + lomant) * pow(2.0, expon - 63)
return sign * f

def _write_short(f, x):
Expand Down Expand Up @@ -233,10 +233,10 @@ def _write_float(f, x):
expon = expon | sign
fmant = math.ldexp(fmant, 32)
fsmant = math.floor(fmant)
himant = long(fsmant)
himant = int(fsmant)
fmant = math.ldexp(fmant - fsmant, 32)
fsmant = math.floor(fmant)
lomant = long(fsmant)
lomant = int(fsmant)
_write_short(f, expon)
_write_long(f, himant)
_write_long(f, lomant)
Expand Down
2 changes: 1 addition & 1 deletion Lib/asynchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def handle_read (self):
# no terminator, collect it all
self.collect_incoming_data (self.ac_in_buffer)
self.ac_in_buffer = ''
elif isinstance(terminator, int) or isinstance(terminator, long):
elif isinstance(terminator, int) or isinstance(terminator, int):
# numeric terminator
n = terminator
if lb < n:
Expand Down
2 changes: 1 addition & 1 deletion Lib/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def urlsafe_b64decode(s):
_b32tab = _b32alphabet.items()
_b32tab.sort()
_b32tab = [v for k, v in _b32tab]
_b32rev = dict([(v, long(k)) for k, v in _b32alphabet.items()])
_b32rev = dict([(v, int(k)) for k, v in _b32alphabet.items()])


def b32encode(s):
Expand Down
6 changes: 3 additions & 3 deletions Lib/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def copy(x):

def _copy_immutable(x):
return x
for t in (type(None), int, long, float, bool, str, tuple,
for t in (type(None), int, int, float, bool, str, tuple,
frozenset, type, xrange, types.ClassType,
types.BuiltinFunctionType,
types.FunctionType):
Expand Down Expand Up @@ -178,7 +178,7 @@ def _deepcopy_atomic(x, memo):
return x
d[type(None)] = _deepcopy_atomic
d[int] = _deepcopy_atomic
d[long] = _deepcopy_atomic
d[int] = _deepcopy_atomic
d[float] = _deepcopy_atomic
d[bool] = _deepcopy_atomic
try:
Expand Down Expand Up @@ -315,7 +315,7 @@ class _EmptyClass:
pass

def _test():
l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'],
l = [None, 1, 2, 3.14, 'xyzzy', (1, 2), [3.14, 'abc'],
{'abc': 'ABC'}, (), [], {}]
l1 = copy(l)
print l1==l
Expand Down
4 changes: 2 additions & 2 deletions Lib/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def has_header(self, sample):

for col in columnTypes.keys():

for thisType in [int, long, float, complex]:
for thisType in [int, int, float, complex]:
try:
thisType(row[col])
break
Expand All @@ -380,7 +380,7 @@ def has_header(self, sample):
thisType = len(row[col])

# treat longs as ints
if thisType == long:
if thisType == int:
thisType = int

if thisType != columnTypes[col]:
Expand Down
6 changes: 3 additions & 3 deletions Lib/ctypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def create_string_buffer(init, size=None):
buf = buftype()
buf.value = init
return buf
elif isinstance(init, (int, long)):
elif isinstance(init, (int, int)):
buftype = c_char * init
buf = buftype()
return buf
Expand Down Expand Up @@ -285,7 +285,7 @@ def create_unicode_buffer(init, size=None):
buf = buftype()
buf.value = init
return buf
elif isinstance(init, (int, long)):
elif isinstance(init, (int, int)):
buftype = c_wchar * init
buf = buftype()
return buf
Expand Down Expand Up @@ -356,7 +356,7 @@ def __getattr__(self, name):

def __getitem__(self, name_or_ordinal):
func = self._FuncPtr((name_or_ordinal, self))
if not isinstance(name_or_ordinal, (int, long)):
if not isinstance(name_or_ordinal, (int, int)):
func.__name__ = name_or_ordinal
return func

Expand Down
2 changes: 1 addition & 1 deletion Lib/ctypes/test/test_as_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_longlong_callbacks(self):
f.argtypes = [c_longlong, MyCallback]

def callback(value):
self.failUnless(isinstance(value, (int, long)))
self.failUnless(isinstance(value, (int, int)))
return value & 0x7FFFFFFF

cb = MyCallback(callback)
Expand Down
2 changes: 1 addition & 1 deletion Lib/ctypes/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def test_longlong_callbacks(self):
f.argtypes = [c_longlong, MyCallback]

def callback(value):
self.failUnless(isinstance(value, (int, long)))
self.failUnless(isinstance(value, (int, int)))
return value & 0x7FFFFFFF

cb = MyCallback(callback)
Expand Down
2 changes: 1 addition & 1 deletion Lib/ctypes/test/test_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_floats(self):
for t in float_types:
self.failUnlessEqual(t(2.0).value, 2.0)
self.failUnlessEqual(t(2).value, 2.0)
self.failUnlessEqual(t(2L).value, 2.0)
self.failUnlessEqual(t(2).value, 2.0)

def test_integers(self):
# integers cannot be constructed from floats
Expand Down
16 changes: 8 additions & 8 deletions Lib/ctypes/test/test_pointers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float]
python_types = [int, int, int, int, int, long,
int, long, long, long, float, float]
python_types = [int, int, int, int, int, int,
int, int, int, int, float, float]

class PointersTestCase(unittest.TestCase):

Expand Down Expand Up @@ -160,16 +160,16 @@ def test_bug_1467852(self):
def test_c_void_p(self):
# http://sourceforge.net/tracker/?func=detail&aid=1518190&group_id=5470&atid=105470
if sizeof(c_void_p) == 4:
self.failUnlessEqual(c_void_p(0xFFFFFFFFL).value,
self.failUnlessEqual(c_void_p(0xFFFFFFFF).value,
c_void_p(-1).value)
self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
elif sizeof(c_void_p) == 8:
self.failUnlessEqual(c_void_p(0xFFFFFFFFL).value,
0xFFFFFFFFL)
self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
self.failUnlessEqual(c_void_p(0xFFFFFFFF).value,
0xFFFFFFFF)
self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFFL).value,
self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)

self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
Expand Down
2 changes: 1 addition & 1 deletion Lib/ctypes/test/test_prototypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def positive_address(a):
# View the bits in `a` as unsigned instead.
import struct
num_bits = struct.calcsize("P") * 8 # num bits in native machine address
a += 1L << num_bits
a += 1 << num_bits
assert a >= 0
return a

Expand Down
20 changes: 10 additions & 10 deletions Lib/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def __new__(cls, value="0", context=None):
return self

# From an integer
if isinstance(value, (int,long)):
if isinstance(value, (int,int)):
if value >= 0:
self._sign = 0
else:
Expand All @@ -561,7 +561,7 @@ def __new__(cls, value="0", context=None):
if value[0] not in (0,1):
raise ValueError, 'Invalid sign'
for digit in value[1]:
if not isinstance(digit, (int,long)) or digit < 0:
if not isinstance(digit, (int,int)) or digit < 0:
raise ValueError, "The second value in the tuple must be composed of non negative integer elements."

self._sign = value[0]
Expand Down Expand Up @@ -740,32 +740,32 @@ def __cmp__(self, other, context=None):
return 1

def __eq__(self, other):
if not isinstance(other, (Decimal, int, long)):
if not isinstance(other, (Decimal, int, int)):
return NotImplemented
return self.__cmp__(other) == 0

def __ne__(self, other):
if not isinstance(other, (Decimal, int, long)):
if not isinstance(other, (Decimal, int, int)):
return NotImplemented
return self.__cmp__(other) != 0

def __lt__(self, other):
if not isinstance(other, (Decimal, int, long)):
if not isinstance(other, (Decimal, int, int)):
return NotImplemented
return self.__cmp__(other) < 0

def __le__(self, other):
if not isinstance(other, (Decimal, int, long)):
if not isinstance(other, (Decimal, int, int)):
return NotImplemented
return self.__cmp__(other) <= 0

def __gt__(self, other):
if not isinstance(other, (Decimal, int, long)):
if not isinstance(other, (Decimal, int, int)):
return NotImplemented
return self.__cmp__(other) > 0

def __ge__(self, other):
if not isinstance(other, (Decimal, int, long)):
if not isinstance(other, (Decimal, int, int)):
return NotImplemented
return self.__cmp__(other) >= 0

Expand Down Expand Up @@ -1529,7 +1529,7 @@ def __long__(self):
Equivalent to long(int(self))
"""
return long(self.__int__())
return int(self.__int__())

def _fix(self, context):
"""Round if it is necessary to keep self within prec precision.
Expand Down Expand Up @@ -2986,7 +2986,7 @@ def _convert_other(other):
"""
if isinstance(other, Decimal):
return other
if isinstance(other, (int, long)):
if isinstance(other, (int, int)):
return Decimal(other)
return NotImplemented

Expand Down
2 changes: 1 addition & 1 deletion Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def disassemble(co, lasti=-1):
extended_arg = 0
i = i+2
if op == EXTENDED_ARG:
extended_arg = oparg*65536L
extended_arg = oparg*65536
print repr(oparg).rjust(5),
if op in hasconst:
print '(' + repr(co.co_consts[oparg]) + ')',
Expand Down
6 changes: 3 additions & 3 deletions Lib/email/test/test_email_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ def test_japanese_codecs(self):
[('Hello World!', None),
('\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
('Gr\xfc\xdf Gott!', 'iso-8859-1')])
long = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
h = Header(long, j, header_name="Subject")
int = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
h = Header(int, j, header_name="Subject")
# test a very long header
enc = h.encode()
# TK: splitting point may differ by codec design and/or Header encoding
eq(enc , """\
=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?=
=?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""")
# TK: full decode comparison
eq(h.__unicode__().encode('euc-jp'), long)
eq(h.__unicode__().encode('euc-jp'), int)

def test_payload_encoding(self):
jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
Expand Down
6 changes: 3 additions & 3 deletions Lib/email/test/test_email_codecs_renamed.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ def test_japanese_codecs(self):
[('Hello World!', None),
('\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
('Gr\xfc\xdf Gott!', 'iso-8859-1')])
long = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
h = Header(long, j, header_name="Subject")
int = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
h = Header(int, j, header_name="Subject")
# test a very long header
enc = h.encode()
# TK: splitting point may differ by codec design and/or Header encoding
eq(enc , """\
=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?=
=?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""")
# TK: full decode comparison
eq(h.__unicode__().encode('euc-jp'), long)
eq(h.__unicode__().encode('euc-jp'), int)

def test_payload_encoding(self):
jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
Expand Down
4 changes: 2 additions & 2 deletions Lib/ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def size(self, filename):
try:
return int(s)
except (OverflowError, ValueError):
return long(s)
return int(s)

def mkd(self, dirname):
'''Make a directory, return its full pathname.'''
Expand Down Expand Up @@ -564,7 +564,7 @@ def parse150(resp):
try:
return int(s)
except (OverflowError, ValueError):
return long(s)
return int(s)


_227_re = None
Expand Down
4 changes: 2 additions & 2 deletions Lib/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def install(self, unicode=False, names=None):

class GNUTranslations(NullTranslations):
# Magic number of .mo files
LE_MAGIC = 0x950412deL
BE_MAGIC = 0xde120495L
LE_MAGIC = 0x950412de
BE_MAGIC = 0xde120495

def _parse(self, fp):
"""Override this method to support alternative .mo formats."""
Expand Down
6 changes: 3 additions & 3 deletions Lib/gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def U32(i):
If it's >= 2GB when viewed as a 32-bit unsigned int, return a long.
"""
if i < 0:
i += 1L << 32
i += 1 << 32
return i

def LOWU32(i):
"""Return the low-order 32 bits of an int, as a non-negative int."""
return i & 0xFFFFFFFFL
return i & 0xFFFFFFFF

def write32(output, value):
output.write(struct.pack("<l", value))
Expand Down Expand Up @@ -148,7 +148,7 @@ def _write_gzip_header(self):
if fname:
flags = FNAME
self.fileobj.write(chr(flags))
write32u(self.fileobj, long(time.time()))
write32u(self.fileobj, int(time.time()))
self.fileobj.write('\002')
self.fileobj.write('\377')
if fname:
Expand Down
Loading

0 comments on commit e2a383d

Please sign in to comment.