Bug report
PyMember_SetOne() stores the result of the conversion before checking for an error, so a failed assignment leaves a garbage value in the attribute.
>>> e = UnicodeDecodeError('utf-8', b'x', 0, 1, 'bad')
>>> e.start
0
>>> e.start = 2**1000
Traceback (most recent call last):
...
OverflowError: Python int too large to convert to C ssize_t
>>> e.start
-1
This affects the Py_T_LONG, Py_T_LONGLONG, Py_T_PYSSIZET and Py_T_DOUBLE cases. The other integer types already convert, check and only then store.
In 3.14 and newer the value is stored after the check (changed in gh-117657, GH-123211), so only 3.13 is affected.
Linked PRs
Reactions are currently unavailable
Bug report
PyMember_SetOne() stores the result of the conversion before checking for an error, so a failed assignment leaves a garbage value in the attribute.
This affects the Py_T_LONG, Py_T_LONGLONG, Py_T_PYSSIZET and Py_T_DOUBLE cases. The other integer types already convert, check and only then store.
In 3.14 and newer the value is stored after the check (changed in gh-117657, GH-123211), so only 3.13 is affected.
Linked PRs