Skip to content

gh-127065: Make methodcaller thread-safe and re-entrant #127245

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

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review comments
  • Loading branch information
eendebakpt committed Dec 3, 2024
commit ad66951c9ddc92c34bf46f3c18ab901f59420edf
13 changes: 6 additions & 7 deletions Modules/_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ static int _methodcaller_initialize_vectorcall(methodcallerobject* mc)
PyErr_NoMemory();
return -1;
}
memcpy(mc->vectorcall_args, PySequence_Fast_ITEMS(args),
memcpy(mc->vectorcall_args, _PyTuple_ITEMS(args),
nargs * sizeof(PyObject*));
if (kwds && PyDict_Size(kwds)) {
const Py_ssize_t nkwds = PyDict_Size(kwds);
Expand Down Expand Up @@ -1694,6 +1694,10 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (mc == NULL) {
return NULL;
}
mc->vectorcall = NULL;
mc->vectorcall_args = NULL;
mc->vectorcall_kwnames = NULL;
mc->kwds = Py_XNewRef(kwds);

Py_INCREF(name);
PyInterpreterState *interp = _PyInterpreterState_GET();
Expand All @@ -1705,17 +1709,12 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF(mc);
return NULL;
}
mc->kwds = Py_XNewRef(kwds);
mc->vectorcall = NULL;
mc->vectorcall_args = NULL;
mc->vectorcall_kwnames = NULL;

Py_ssize_t vectorcall_size = PyTuple_GET_SIZE(args)
+ (kwds ? PyDict_Size(kwds) : 0);
if (vectorcall_size < (_METHODCALLER_MAX_ARGS)) {
if (_methodcaller_initialize_vectorcall(mc) < 0) {
Py_XDECREF(mc->args);
Py_XDECREF(mc->kwds);
Py_DECREF(mc);
return NULL;
}
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy