summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Modules/_functoolsmodule.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2026-05-07 07:27:37 +0300
committershadchin <[email protected]>2026-05-07 07:57:26 +0300
commitcdd663c58847eced4c810b05edda251c70a10438 (patch)
tree268b4bf9860a9c77564d93a803d7ecfedd3586cd /contrib/tools/python3/Modules/_functoolsmodule.c
parentb6f47db70a8a8e904e3f38bed557097ff00f0b3b (diff)
Update Python 3 to 3.13.13
commit_hash:526db1f6570443324e2690db042314848cd47d2e
Diffstat (limited to 'contrib/tools/python3/Modules/_functoolsmodule.c')
-rw-r--r--contrib/tools/python3/Modules/_functoolsmodule.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/contrib/tools/python3/Modules/_functoolsmodule.c b/contrib/tools/python3/Modules/_functoolsmodule.c
index cbbba322a18..a1682ec4c0e 100644
--- a/contrib/tools/python3/Modules/_functoolsmodule.c
+++ b/contrib/tools/python3/Modules/_functoolsmodule.c
@@ -220,7 +220,9 @@ partial_vectorcall_fallback(PyThreadState *tstate, partialobject *pto,
PyObject *const *args, size_t nargsf,
PyObject *kwnames)
{
+#ifndef Py_GIL_DISABLED
pto->vectorcall = NULL;
+#endif
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
return _PyObject_MakeTpCall(tstate, (PyObject *)pto,
args, nargs, kwnames);
@@ -386,65 +388,72 @@ static PyObject *
partial_repr(partialobject *pto)
{
PyObject *result = NULL;
- PyObject *arglist;
- PyObject *mod;
- PyObject *name;
+ PyObject *arglist = NULL;
+ PyObject *mod = NULL;
+ PyObject *name = NULL;
Py_ssize_t i, n;
PyObject *key, *value;
int status;
status = Py_ReprEnter((PyObject *)pto);
if (status != 0) {
- if (status < 0)
+ if (status < 0) {
return NULL;
+ }
return PyUnicode_FromString("...");
}
+ /* Reference arguments in case they change */
+ PyObject *fn = Py_NewRef(pto->fn);
+ PyObject *args = Py_NewRef(pto->args);
+ PyObject *kw = Py_NewRef(pto->kw);
+ assert(PyTuple_Check(args));
+ assert(PyDict_Check(kw));
arglist = PyUnicode_FromString("");
- if (arglist == NULL)
+ if (arglist == NULL) {
goto done;
+ }
/* Pack positional arguments */
- assert (PyTuple_Check(pto->args));
- n = PyTuple_GET_SIZE(pto->args);
+ n = PyTuple_GET_SIZE(args);
for (i = 0; i < n; i++) {
Py_SETREF(arglist, PyUnicode_FromFormat("%U, %R", arglist,
- PyTuple_GET_ITEM(pto->args, i)));
- if (arglist == NULL)
+ PyTuple_GET_ITEM(args, i)));
+ if (arglist == NULL) {
goto done;
+ }
}
/* Pack keyword arguments */
- assert (PyDict_Check(pto->kw));
- for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) {
+ for (i = 0; PyDict_Next(kw, &i, &key, &value);) {
/* Prevent key.__str__ from deleting the value. */
Py_INCREF(value);
Py_SETREF(arglist, PyUnicode_FromFormat("%U, %S=%R", arglist,
key, value));
Py_DECREF(value);
- if (arglist == NULL)
+ if (arglist == NULL) {
goto done;
+ }
}
mod = PyType_GetModuleName(Py_TYPE(pto));
if (mod == NULL) {
- goto error;
+ goto done;
}
+
name = PyType_GetQualName(Py_TYPE(pto));
if (name == NULL) {
- Py_DECREF(mod);
- goto error;
+ goto done;
}
- result = PyUnicode_FromFormat("%S.%S(%R%U)", mod, name, pto->fn, arglist);
- Py_DECREF(mod);
- Py_DECREF(name);
- Py_DECREF(arglist);
- done:
+ result = PyUnicode_FromFormat("%S.%S(%R%U)", mod, name, fn, arglist);
+done:
+ Py_XDECREF(name);
+ Py_XDECREF(mod);
+ Py_XDECREF(arglist);
+ Py_DECREF(fn);
+ Py_DECREF(args);
+ Py_DECREF(kw);
Py_ReprLeave((PyObject *)pto);
return result;
- error:
- Py_DECREF(arglist);
- Py_ReprLeave((PyObject *)pto);
- return NULL;
}
/* Pickle strategy: