Fix PNG dimension validation test on 32-bit platforms

Expect OverflowError for dimensions that exceed sys.maxsize, since
PyArg_ParseTuple rejects them before the PNG buffer validation runs.
Continue to expect ValueError for invalid dimensions and buffer lengths
that reach the validation code.
This commit is contained in:
Egor Ignatov 2026-11-03 20:36:29 +05:00
parent 0b1b477409
commit 51b159f990

View file

@ -116,7 +116,10 @@ class TestDataTypes(BaseTest):
(rgba, 2**32 + 2, 2),
(rgba, -2, -2),
):
with self.assertRaises(ValueError, msg=repr(args[1:])):
# Dimensions outside Py_ssize_t fail during argument parsing, before
# the buffer length and dimension validation can raise ValueError.
error = OverflowError if any(x > sys.maxsize for x in args[1:]) else ValueError
with self.assertRaises(error, msg=repr(args[1:])):
png_from_32bit_rgba_data(*args)
with self.assertRaises(OverflowError):
png_from_32bit_rgba_data(rgba, 2, 2**64 + 2)