-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
GH-141312: Allow only integers to longrangeiter_setstate state #141317
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
aea82e8
4eaee49
c11596e
33190fe
8d08e5a
4011aa2
7e3c5af
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1042,6 +1042,12 @@ longrangeiter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) | |||||||||||||||||||
| static PyObject * | ||||||||||||||||||||
| longrangeiter_setstate(PyObject *op, PyObject *state) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (!PyLong_CheckExact(state)) { | ||||||||||||||||||||
| PyErr_Format(PyExc_TypeError, | ||||||||||||||||||||
| "'%T' object cannot be interpreted as an integer", state); | ||||||||||||||||||||
|
||||||||||||||||||||
| return NULL; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
1050
to
1053
Member
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.
Suggested change
Contributor
Author
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. This is exactly what I added before checking what
Member
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. Oh so that is the message of rangeiter. Ok keep it the same.
Member
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. The proposed message is better.
Member
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.
But there is no good reason to do this. It would only complicate the code without adding any benefit. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| longrangeiterobject *r = (longrangeiterobject*)op; | ||||||||||||||||||||
| PyObject *zero = _PyLong_GetZero(); // borrowed reference | ||||||||||||||||||||
| int cmp; | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
setstate.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.
Range iter give following error messages before last changes:
'float' object cannot be interpreted as an integer'str' object cannot be interpreted as an integer