FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue #16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and · python/cpython@4c7dc48 · GitHub

Repository navigation

Commit 4c7dc48

Browse files
Issue #16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and
arbitrary precision integers added in Tcl 8.5.
2 parents ea534f7 + ea134da commit 4c7dc48

3 files changed

Lines changed: 233 additions & 23 deletions

File tree

‎Lib/test/test_tcl.py‎

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,20 @@ def testUnsetVarException(self):
133133
tcl = self.interp
134134
self.assertRaises(TclError,tcl.unsetvar,'a')
135135

136+
def get_integers(self):
137+
integers = (0, 1, -1, 2**31-1, -2**31, 2**31, -2**31-1, 2**63-1, -2**63)
138+
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
139+
integers += (2**63, -2**63-1, 2**1000, -2**1000)
140+
return integers
141+
136142
def test_getint(self):
137143
tcl = self.interp.tk
138-
self.assertEqual(tcl.getint(' 42 '), 42)
144+
for i in self.get_integers():
145+
self.assertEqual(tcl.getint(' %d ' % i), i)
146+
self.assertEqual(tcl.getint(' %#o ' % i), i)
147+
self.assertEqual(tcl.getint(' %#x ' % i), i)
148+
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
149+
self.assertRaises(TclError, tcl.getint, str(2**1000))
139150
self.assertEqual(tcl.getint(42), 42)
140151
self.assertRaises(TypeError, tcl.getint)
141152
self.assertRaises(TypeError, tcl.getint, '42', '10')
@@ -270,7 +281,7 @@ def check(expr, expected):
270281
check('"a\xbd\u20ac"', 'a\xbd\u20ac')
271282
check(r'"a\xbd\u20ac"', 'a\xbd\u20ac')
272283
check(r'"a\0b"', 'a\x00b')
273-
if tcl_version >= (8, 5):
284+
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
274285
check('2**64', str(2**64))
275286

276287
def test_exprdouble(self):
@@ -302,7 +313,7 @@ def check(expr, expected):
302313
check('[string length "a\xbd\u20ac"]', 3.0)
303314
check(r'[string length "a\xbd\u20ac"]', 3.0)
304315
self.assertRaises(TclError, tcl.exprdouble, '"abc"')
305-
if tcl_version >= (8, 5):
316+
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
306317
check('2**64', float(2**64))
307318

308319
def test_exprlong(self):
@@ -334,7 +345,7 @@ def check(expr, expected):
334345
check('[string length "a\xbd\u20ac"]', 3)
335346
check(r'[string length "a\xbd\u20ac"]', 3)
336347
self.assertRaises(TclError, tcl.exprlong, '"abc"')
337-
if tcl_version >= (8, 5):
348+
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
338349
self.assertRaises(TclError, tcl.exprlong, '2**64')
339350

340351
def test_exprboolean(self):
@@ -375,7 +386,7 @@ def check(expr, expected):
375386
check('[string length "a\xbd\u20ac"]', True)
376387
check(r'[string length "a\xbd\u20ac"]', True)
377388
self.assertRaises(TclError, tcl.exprboolean, '"abc"')
378-
if tcl_version >= (8, 5):
389+
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
379390
check('2**64', True)
380391

381392
def test_booleans(self):
@@ -397,6 +408,21 @@ def check(expr, expected):
397408
check('1 < 2', True)
398409
check('1 > 2', False)
399410

411+
def test_expr_bignum(self):
412+
tcl = self.interp
413+
for i in self.get_integers():
414+
result = tcl.call('expr', str(i))
415+
if self.wantobjects:
416+
self.assertEqual(result, i)
417+
self.assertIsInstance(result, int)
418+
else:
419+
self.assertEqual(result, str(i))
420+
self.assertIsInstance(result, str)
421+
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
422+
result = tcl.call('expr', str(2**1000))
423+
self.assertEqual(result, str(2**1000))
424+
self.assertIsInstance(result, str)
425+
400426
def test_passing_values(self):
401427
def passValue(value):
402428
return self.interp.call('set', '_', value)
@@ -414,8 +440,10 @@ def passValue(value):
414440
b'str\xc0\x80ing' if self.wantobjects else 'str\xc0\x80ing')
415441
self.assertEqual(passValue(b'str\xbding'),
416442
b'str\xbding' if self.wantobjects else 'str\xbding')
417-
for i in (0, 1, -1, 2**31-1, -2**31):
443+
for i in self.get_integers():
418444
self.assertEqual(passValue(i), i if self.wantobjects else str(i))
445+
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
446+
self.assertEqual(passValue(2**1000), str(2**1000))
419447
for f in (0.0, 1.0, -1.0, 1/3,
420448
sys.float_info.min, sys.float_info.max,
421449
-sys.float_info.min, -sys.float_info.max):
@@ -475,8 +503,10 @@ def float_eq(actual, expected):
475503
check(b'str\x00ing', 'str\x00ing')
476504
check(b'str\xc0\x80ing', 'str\xc0\x80ing')
477505
check(b'str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac')
478-
for i in (0, 1, -1, 2**31-1, -2**31):
506+
for i in self.get_integers():
479507
check(i, str(i))
508+
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
509+
check(2**1000, str(2**1000))
480510
for f in (0.0, 1.0, -1.0):
481511
check(f, repr(f))
482512
for f in (1/3.0, sys.float_info.min, sys.float_info.max,

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Core and Builtins
1616
Library
1717
-------
1818

19+
- Issue #16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and
20+
arbitrary precision integers added in Tcl 8.5.
21+
1922
- Issue #23834: Fix socket.sendto(), use the C Py_ssize_t type to store the
2023
result of sendto() instead of the C int type.
2124

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL