Skip to content

Commit 994f04d

Browse files
Issue #28998: More APIs now support longs as well as ints.
1 parent 58c2c6e commit 994f04d

23 files changed

Lines changed: 70 additions & 44 deletions

File tree

Lib/asynchat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def handle_read (self):
133133
# no terminator, collect it all
134134
self.collect_incoming_data (self.ac_in_buffer)
135135
self.ac_in_buffer = ''
136-
elif isinstance(terminator, int) or isinstance(terminator, long):
136+
elif isinstance(terminator, (int, long)):
137137
# numeric terminator
138138
n = terminator
139139
if lb < n:

Lib/compiler/pyassem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def getArgCount(args):
581581

582582
def twobyte(val):
583583
"""Convert an int argument into high and low bytes"""
584-
assert isinstance(val, int)
584+
assert isinstance(val, (int, long))
585585
return divmod(val, 256)
586586

587587
class LineAddrTable:

Lib/compiler/transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ def get_docstring(self, node, n=None):
15261526
def debug_tree(tree):
15271527
l = []
15281528
for elt in tree:
1529-
if isinstance(elt, int):
1529+
if isinstance(elt, (int, long)):
15301530
l.append(_names.get(elt, elt))
15311531
elif isinstance(elt, str):
15321532
l.append(elt)

Lib/idlelib/PyShell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ def read(self, size=-1):
13701370
raise ValueError("read from closed file")
13711371
if size is None:
13721372
size = -1
1373-
elif not isinstance(size, int):
1373+
elif not isinstance(size, (int, long)):
13741374
raise TypeError('must be int, not ' + type(size).__name__)
13751375
result = self._line_buffer
13761376
self._line_buffer = ''
@@ -1393,7 +1393,7 @@ def readline(self, size=-1):
13931393
raise ValueError("read from closed file")
13941394
if size is None:
13951395
size = -1
1396-
elif not isinstance(size, int):
1396+
elif not isinstance(size, (int, long)):
13971397
raise TypeError('must be int, not ' + type(size).__name__)
13981398
line = self._line_buffer or self.shell.readline()
13991399
if size < 0:

Lib/imaplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ def Time2Internaldate(date_time):
14091409
be in the correct format.
14101410
"""
14111411

1412-
if isinstance(date_time, (int, float)):
1412+
if isinstance(date_time, (int, long, float)):
14131413
tt = time.localtime(date_time)
14141414
elif isinstance(date_time, (tuple, time.struct_time)):
14151415
tt = date_time

Lib/lib-tk/Tkinter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,9 +1174,9 @@ def _options(self, cnf, kw = None):
11741174
elif isinstance(v, (tuple, list)):
11751175
nv = []
11761176
for item in v:
1177-
if not isinstance(item, (basestring, int)):
1177+
if not isinstance(item, (basestring, int, long)):
11781178
break
1179-
elif isinstance(item, int):
1179+
elif isinstance(item, (int, long)):
11801180
nv.append('%d' % item)
11811181
else:
11821182
# format it to proper Tcl code if it contains space

Lib/lib-tk/turtle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def __mul__(self, other):
276276
return self[0]*other[0]+self[1]*other[1]
277277
return Vec2D(self[0]*other, self[1]*other)
278278
def __rmul__(self, other):
279-
if isinstance(other, int) or isinstance(other, float):
279+
if isinstance(other, (int, long, float)):
280280
return Vec2D(self[0]*other, self[1]*other)
281281
def __sub__(self, other):
282282
return Vec2D(self[0]-other[0], self[1]-other[1])
@@ -2352,7 +2352,7 @@ def pen(self, pen=None, **pendict):
23522352
self._resizemode = p["resizemode"]
23532353
if "stretchfactor" in p:
23542354
sf = p["stretchfactor"]
2355-
if isinstance(sf, (int, float)):
2355+
if isinstance(sf, (int, long, float)):
23562356
sf = (sf, sf)
23572357
self._stretchfactor = sf
23582358
if "outline" in p:

Lib/lib2to3/pgen2/pgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def make_label(self, c, label):
7474
else:
7575
# A named token (NAME, NUMBER, STRING)
7676
itoken = getattr(token, label, None)
77-
assert isinstance(itoken, int), label
77+
assert isinstance(itoken, (int, long)), label
7878
assert itoken in token.tok_name, label
7979
if itoken in c.tokens:
8080
return c.tokens[itoken]

Lib/logging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ def log(self, level, msg, *args, **kwargs):
12221222
12231223
logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
12241224
"""
1225-
if not isinstance(level, int):
1225+
if not isinstance(level, (int, long)):
12261226
if raiseExceptions:
12271227
raise TypeError("level must be an integer")
12281228
else:

Lib/multiprocessing/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __repr__(self):
8686

8787

8888
def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None):
89-
assert maxtasks is None or (type(maxtasks) == int and maxtasks > 0)
89+
assert maxtasks is None or (type(maxtasks) in (int, long) and maxtasks > 0)
9090
put = outqueue.put
9191
get = inqueue.get
9292
if hasattr(inqueue, '_writer'):

0 commit comments

Comments
 (0)