mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Ensure that width and precision in string formatting test have type int, not long.
Fix a regression from changeset d544873d62e9 (issue #15989).
This commit is contained in:
parent
302ad8d126
commit
18a13933f9
1 changed files with 12 additions and 12 deletions
|
@ -1114,19 +1114,19 @@ class MixinStrUnicodeUserStringTest:
|
||||||
self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.))
|
self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.))
|
||||||
self.checkraises(ValueError, '%10', '__mod__', (42,))
|
self.checkraises(ValueError, '%10', '__mod__', (42,))
|
||||||
|
|
||||||
if _testcapi.PY_SSIZE_T_MAX < sys.maxint:
|
width = int(_testcapi.PY_SSIZE_T_MAX + 1)
|
||||||
self.checkraises(OverflowError, '%*s', '__mod__',
|
if width <= sys.maxint:
|
||||||
(_testcapi.PY_SSIZE_T_MAX + 1, ''))
|
self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
|
||||||
if _testcapi.INT_MAX < sys.maxint:
|
prec = int(_testcapi.INT_MAX + 1)
|
||||||
self.checkraises(OverflowError, '%.*f', '__mod__',
|
if prec <= sys.maxint:
|
||||||
(_testcapi.INT_MAX + 1, 1. / 7))
|
self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
|
||||||
# Issue 15989
|
# Issue 15989
|
||||||
if 1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1) <= sys.maxint:
|
width = int(1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1))
|
||||||
self.checkraises(OverflowError, '%*s', '__mod__',
|
if width <= sys.maxint:
|
||||||
(1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), ''))
|
self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
|
||||||
if _testcapi.UINT_MAX < sys.maxint:
|
prec = int(_testcapi.UINT_MAX + 1)
|
||||||
self.checkraises(OverflowError, '%.*f', '__mod__',
|
if prec <= sys.maxint:
|
||||||
(_testcapi.UINT_MAX + 1, 1. / 7))
|
self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
|
||||||
|
|
||||||
class X(object): pass
|
class X(object): pass
|
||||||
self.checkraises(TypeError, 'abc', '__mod__', X())
|
self.checkraises(TypeError, 'abc', '__mod__', X())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue