-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
int.from_bytes
crashes if byteorder
is a string subclass
#98783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
CC @sweeneyde as blame owner |
So it looks like that made the switch from Replacing the assertion seems reasonable to me, since |
Related: faster-cpython/ideas#486 would add back in a hash check for these cases, which would restore the hash check that was in |
There also seems to be a discrepancy between whether or not cpython/Include/cpython/unicodeobject.h Lines 948 to 949 in 3e07f82
and this error check: Lines 3422 to 3425 in 3e07f82
At the time it was added, error checks were needed because PyUnicode_READY could fail. But since f9c9354, I think it should be safe to delete the "Returns -1 on failure" comment and remove the NULL check in ceval.c. |
Other places that crash because of this:
|
…code_Equal` (pythonGH-98806) (cherry picked from commit 76f989d) Co-authored-by: Nikita Sobolev <[email protected]>
Thanks for finding and fixing this! I went ahead and opened #98879 about the error handling. |
Here's a minimal reproduction:
I think this happes because of these lines:
cpython/Objects/unicodeobject.c
Lines 10444 to 10453 in bded5ed
_PyUnicode_Equal
usesassert(PyUnicode_CheckExact(...))
, while many function (includingint_from_bytes_impl
) usePyUnicode_Check()
or just parsestr
objects from args.cpython/Objects/longobject.c
Lines 6167 to 6170 in bded5ed
Probably other functions that use
_PyUnicode_Equal
are also affected.I would like to raise a question: shouldn't it be
assert(PyUnicode_Check(...))
in_PyUnicode_Equal
?I would like to send a PR with the fix!
The text was updated successfully, but these errors were encountered: