mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError for
negative arguments. Previously, it raised TypeError. Thanks Lisandro Dalcin.
This commit is contained in:
parent
6a743d3694
commit
4015f62e39
6 changed files with 41 additions and 10 deletions
|
@ -48,7 +48,7 @@ def with_warning_restore(func):
|
|||
def deprecated_err(func, *args):
|
||||
try:
|
||||
func(*args)
|
||||
except (struct.error, TypeError):
|
||||
except (struct.error, OverflowError):
|
||||
pass
|
||||
except DeprecationWarning:
|
||||
if not PY_STRUCT_OVERFLOW_MASKING:
|
||||
|
@ -185,7 +185,7 @@ class StructTest(unittest.TestCase):
|
|||
|
||||
def test_native_qQ(self):
|
||||
# can't pack -1 as unsigned regardless
|
||||
self.assertRaises((struct.error, TypeError), struct.pack, "Q", -1)
|
||||
self.assertRaises((struct.error, OverflowError), struct.pack, "Q", -1)
|
||||
# can't pack string as 'q' regardless
|
||||
self.assertRaises(struct.error, struct.pack, "q", "a")
|
||||
# ditto, but 'Q'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue