-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
GH-132775: Fix argument parsing for _interpqueues.put()
#137686
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?
Conversation
Modules/_interpqueuesmodule.c
Outdated
@@ -1603,7 +1603,7 @@ queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds) | |||
PyObject *obj; | |||
int unboundarg = -1; | |||
int fallbackarg = -1; | |||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O|ii$p:put", kwlist, | |||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O|ii:put", kwlist, |
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.
I think that this is the correct solution:
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O|ii:put", kwlist, | |
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O|i$p:put", kwlist, |
Please add tests with the fallback
argument equal to None
, -1
, 2**1000
-- there should be different behavior for patched and unpatched code. Also, fallback
is now keyword-only. And passing unsupported keyword argument could crash the old code.
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.
I went with 'i' because that's what .create()
uses, but I'm now not sure which is more correct. @ericsnowcurrently?
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.
#134440 removed fmt
("i") and added keyword-only boolean fallback
("p"). We usually make booleans keyword-only.
fallback
has only three state -- _PyXIDATA_XIDATA_ONLY (0), _PyXIDATA_FULL_FALLBACK (1), and default negative value used to distinguish "no argument" from passed value. Other positive values are errors.
If it was also added in other functions, it most likely should be keyword-only boolean too.
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.
I've done as you suggest. Note the changes I had to make to .create()
, though.
It would be good to get this in to 3.14rc2 (now this Thu). Feel free to take over the branch.
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.
Unfortunately, queues.put()
is never called with the fallback
argument, so we do not have examples of non-default values. queues.create()
is only called with the default value -1. Maybe @ericsnowcurrently planned to add named constants for fallback
, as for unbound
. Or he started with integers and planned to make it boolean. Only he can answer these questions, we do not have enough information.
Bug introduced in #134440, cc @serhiy-storchaka @ericsnowcurrently. Also xref gh-137685.
A