Skip to content

Commit f6467a6

Browse files
committed
fix compatibility issues between long support and Python 3
1 parent e5f65c0 commit f6467a6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tabulate.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from functools import partial
1515
_none_type = type(None)
1616
_int_type = int
17+
_long_type = long
1718
_float_type = float
1819
_text_type = unicode
1920
_binary_type = str
@@ -26,6 +27,7 @@ def _is_file(f):
2627
from functools import reduce, partial
2728
_none_type = type(None)
2829
_int_type = int
30+
_long_type = int
2931
_float_type = float
3032
_text_type = str
3133
_binary_type = bytes
@@ -317,8 +319,6 @@ def _type(string, has_invisible=True):
317319
True
318320
>>> _type("1") is type(1)
319321
True
320-
>>> _type(1L) is type(1L)
321-
True
322322
>>> _type('\x1b[31m42\x1b[0m') is type(42)
323323
True
324324
>>> _type('\x1b[31m42\x1b[0m') is type(42)
@@ -336,8 +336,8 @@ def _type(string, has_invisible=True):
336336
return _text_type
337337
elif _isint(string):
338338
return int
339-
elif _isint(string, long):
340-
return long
339+
elif _isint(string, _long_type):
340+
return _long_type
341341
elif _isnumber(string):
342342
return float
343343
elif isinstance(string, _binary_type):
@@ -517,7 +517,7 @@ def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
517517
if val is None:
518518
return missingval
519519

520-
if valtype in [int, long, _text_type]:
520+
if valtype in [int, _long_type, _text_type]:
521521
return "{0}".format(val)
522522
elif valtype is _binary_type:
523523
try:

test/test_regression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ def test_alignment_of_decimal_numbers_with_ansi_color():
209209

210210

211211
def test_long_integers():
212-
"Regression: long integers should be printed as integers (issue #TBD)"
213-
table = [[18446744073709551614L]]
212+
"Regression: long integers should be printed as integers (issue #48)"
213+
table = [[18446744073709551614]]
214214
result = tabulate(table, tablefmt="plain")
215215
expected = u"18446744073709551614"
216216
assert_equal(result, expected)

0 commit comments

Comments
 (0)