-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-130824: Add tests for NULL
in PyLong_*AndOverflow
functions
#130828
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -625,7 +625,8 @@ pylong_aslongandoverflow(PyObject *module, PyObject *arg) | |
int overflow = UNINITIALIZED_INT; | ||
long value = PyLong_AsLongAndOverflow(arg, &overflow); | ||
if (value == -1 && PyErr_Occurred()) { | ||
assert(overflow == -1); | ||
// overflow can be 0 if a seperate exception occurred | ||
ZeroIntensity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert(overflow == -1 || overflow == 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is not it always There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not with OverflowError. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, TypeError too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OverflowError is not raised. In case of an integer overflow, Isn't it always |
||
return NULL; | ||
} | ||
return Py_BuildValue("li", value, overflow); | ||
|
@@ -671,7 +672,8 @@ pylong_aslonglongandoverflow(PyObject *module, PyObject *arg) | |
int overflow = UNINITIALIZED_INT; | ||
long long value = PyLong_AsLongLongAndOverflow(arg, &overflow); | ||
if (value == -1 && PyErr_Occurred()) { | ||
assert(overflow == -1); | ||
// overflow can be 0 if a seperate exception occurred | ||
ZeroIntensity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert(overflow == -1 || overflow == 0); | ||
ZeroIntensity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return NULL; | ||
} | ||
return Py_BuildValue("Li", value, overflow); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really crash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it doesn't: "If any other exception occurs set *overflow to 0 and return -1 as usual." TypeError will be here.