##// END OF EJS Templates
Fix long integer literals....
Thomas Kluyver -
Show More
@@ -1465,7 +1465,7 b' class spawnb(object):'
1465 """This returns the terminal window size of the child tty. The return
1465 """This returns the terminal window size of the child tty. The return
1466 value is a tuple of (rows, cols). """
1466 value is a tuple of (rows, cols). """
1467
1467
1468 TIOCGWINSZ = getattr(termios, 'TIOCGWINSZ', 1074295912L)
1468 TIOCGWINSZ = getattr(termios, 'TIOCGWINSZ', 1074295912)
1469 s = struct.pack('HHHH', 0, 0, 0, 0)
1469 s = struct.pack('HHHH', 0, 0, 0, 0)
1470 x = fcntl.ioctl(self.fileno(), TIOCGWINSZ, s)
1470 x = fcntl.ioctl(self.fileno(), TIOCGWINSZ, s)
1471 return struct.unpack('HHHH', x)[0:2]
1471 return struct.unpack('HHHH', x)[0:2]
@@ -1487,7 +1487,7 b' class spawnb(object):'
1487 # Newer versions of Linux have totally different values for TIOCSWINSZ.
1487 # Newer versions of Linux have totally different values for TIOCSWINSZ.
1488 # Note that this fix is a hack.
1488 # Note that this fix is a hack.
1489 TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561)
1489 TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561)
1490 if TIOCSWINSZ == 2148037735L: # L is not required in Python >= 2.2.
1490 if TIOCSWINSZ == 2148037735: # L is not required in Python >= 2.2.
1491 TIOCSWINSZ = -2146929561 # Same bits, but with sign.
1491 TIOCSWINSZ = -2146929561 # Same bits, but with sign.
1492 # Note, assume ws_xpixel and ws_ypixel are zero.
1492 # Note, assume ws_xpixel and ws_ypixel are zero.
1493 s = struct.pack('HHHH', r, c, 0, 0)
1493 s = struct.pack('HHHH', r, c, 0, 0)
@@ -39,7 +39,7 b" if os.name == 'nt':"
39 def gui_excepthook(exctype, value, tb):
39 def gui_excepthook(exctype, value, tb):
40 try:
40 try:
41 import ctypes, traceback
41 import ctypes, traceback
42 MB_ICONERROR = 0x00000010L
42 MB_ICONERROR = 0x00000010
43 title = u'Error starting IPython QtConsole'
43 title = u'Error starting IPython QtConsole'
44 msg = u''.join(traceback.format_exception(exctype, value, tb))
44 msg = u''.join(traceback.format_exception(exctype, value, tb))
45 ctypes.windll.user32.MessageBoxW(0, msg, title, MB_ICONERROR)
45 ctypes.windll.user32.MessageBoxW(0, msg, title, MB_ICONERROR)
@@ -718,26 +718,27 b' class TestInt(TraitTestBase):'
718 10.1, -10.1, '10L', '-10L', '10.1', '-10.1', u'10L',
718 10.1, -10.1, '10L', '-10L', '10.1', '-10.1', u'10L',
719 u'-10L', u'10.1', u'-10.1', '10', '-10', u'10', u'-10']
719 u'-10L', u'10.1', u'-10.1', '10', '-10', u'10', u'-10']
720 if not py3compat.PY3:
720 if not py3compat.PY3:
721 _bad_values.extend([10L, -10L, 10*sys.maxint, -10*sys.maxint])
721 _bad_values.extend([long(10), long(-10), 10*sys.maxint, -10*sys.maxint])
722
722
723
723
724 class LongTrait(HasTraits):
724 class LongTrait(HasTraits):
725
725
726 value = Long(99L)
726 value = Long(99 if py3compat.PY3 else long(99))
727
727
728 class TestLong(TraitTestBase):
728 class TestLong(TraitTestBase):
729
729
730 obj = LongTrait()
730 obj = LongTrait()
731
731
732 _default_value = 99L
732 _default_value = 99 if py3compat.PY3 else long(99)
733 _good_values = [10, -10, 10L, -10L]
733 _good_values = [10, -10]
734 _bad_values = ['ten', u'ten', [10], [10l], {'ten': 10},(10,),(10L,),
734 _bad_values = ['ten', u'ten', [10], {'ten': 10},(10,),
735 None, 1j, 10.1, -10.1, '10', '-10', '10L', '-10L', '10.1',
735 None, 1j, 10.1, -10.1, '10', '-10', '10L', '-10L', '10.1',
736 '-10.1', u'10', u'-10', u'10L', u'-10L', u'10.1',
736 '-10.1', u'10', u'-10', u'10L', u'-10L', u'10.1',
737 u'-10.1']
737 u'-10.1']
738 if not py3compat.PY3:
738 if not py3compat.PY3:
739 # maxint undefined on py3, because int == long
739 # maxint undefined on py3, because int == long
740 _good_values.extend([10*sys.maxint, -10*sys.maxint])
740 _good_values.extend([long(10), long(-10), 10*sys.maxint, -10*sys.maxint])
741 _bad_values.extend([[long(10)], (long(10),)])
741
742
742 @skipif(py3compat.PY3, "not relevant on py3")
743 @skipif(py3compat.PY3, "not relevant on py3")
743 def test_cast_small(self):
744 def test_cast_small(self):
@@ -762,7 +763,7 b' class TestInteger(TestLong):'
762 if py3compat.PY3:
763 if py3compat.PY3:
763 raise SkipTest("not relevant on py3")
764 raise SkipTest("not relevant on py3")
764
765
765 self.obj.value = 100L
766 self.obj.value = long(100)
766 self.assertEqual(type(self.obj.value), int)
767 self.assertEqual(type(self.obj.value), int)
767
768
768
769
@@ -780,7 +781,7 b' class TestFloat(TraitTestBase):'
780 1j, '10', '-10', '10L', '-10L', '10.1', '-10.1', u'10',
781 1j, '10', '-10', '10L', '-10L', '10.1', '-10.1', u'10',
781 u'-10', u'10L', u'-10L', u'10.1', u'-10.1']
782 u'-10', u'10L', u'-10L', u'10.1', u'-10.1']
782 if not py3compat.PY3:
783 if not py3compat.PY3:
783 _bad_values.extend([10L, -10L])
784 _bad_values.extend([long(10), long(-10)])
784
785
785
786
786 class ComplexTrait(HasTraits):
787 class ComplexTrait(HasTraits):
@@ -796,7 +797,7 b' class TestComplex(TraitTestBase):'
796 10.1j, 10.1+10.1j, 10.1-10.1j]
797 10.1j, 10.1+10.1j, 10.1-10.1j]
797 _bad_values = [u'10L', u'-10L', 'ten', [10], {'ten': 10},(10,), None]
798 _bad_values = [u'10L', u'-10L', 'ten', [10], {'ten': 10},(10,), None]
798 if not py3compat.PY3:
799 if not py3compat.PY3:
799 _bad_values.extend([10L, -10L])
800 _bad_values.extend([long(10), long(-10)])
800
801
801
802
802 class BytesTrait(HasTraits):
803 class BytesTrait(HasTraits):
@@ -810,8 +811,10 b' class TestBytes(TraitTestBase):'
810 _default_value = b'string'
811 _default_value = b'string'
811 _good_values = [b'10', b'-10', b'10L',
812 _good_values = [b'10', b'-10', b'10L',
812 b'-10L', b'10.1', b'-10.1', b'string']
813 b'-10L', b'10.1', b'-10.1', b'string']
813 _bad_values = [10, -10, 10L, -10L, 10.1, -10.1, 1j, [10],
814 _bad_values = [10, -10, 10.1, -10.1, 1j, [10],
814 ['ten'],{'ten': 10},(10,), None, u'string']
815 ['ten'],{'ten': 10},(10,), None, u'string']
816 if not py3compat.PY3:
817 _bad_values.extend([long(10), long(-10)])
815
818
816
819
817 class UnicodeTrait(HasTraits):
820 class UnicodeTrait(HasTraits):
@@ -825,8 +828,10 b' class TestUnicode(TraitTestBase):'
825 _default_value = u'unicode'
828 _default_value = u'unicode'
826 _good_values = ['10', '-10', '10L', '-10L', '10.1',
829 _good_values = ['10', '-10', '10L', '-10L', '10.1',
827 '-10.1', '', u'', 'string', u'string', u"€"]
830 '-10.1', '', u'', 'string', u'string', u"€"]
828 _bad_values = [10, -10, 10L, -10L, 10.1, -10.1, 1j,
831 _bad_values = [10, -10, 10.1, -10.1, 1j,
829 [10], ['ten'], [u'ten'], {'ten': 10},(10,), None]
832 [10], ['ten'], [u'ten'], {'ten': 10},(10,), None]
833 if not py3compat.PY3:
834 _bad_values.extend([long(10), long(-10)])
830
835
831
836
832 class ObjectNameTrait(HasTraits):
837 class ObjectNameTrait(HasTraits):
@@ -901,7 +901,7 b' else:'
901 class Long(TraitType):
901 class Long(TraitType):
902 """A long integer trait."""
902 """A long integer trait."""
903
903
904 default_value = 0L
904 default_value = 0
905 info_text = 'a long'
905 info_text = 'a long'
906
906
907 def validate(self, obj, value):
907 def validate(self, obj, value):
General Comments 0
You need to be logged in to leave comments. Login now