Skip to content
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

[mypyc] Avoid uses of _PyObject_CallMethodOneArg on 3.13 #17526

Merged
merged 2 commits into from
Aug 14, 2024
Merged
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
Next Next commit
[mypyc] Avoid uses of _PyObject_CallMethodOneArg on 3.13
It's no longer available in CPython 3.13 betas.

This fixes some dict primitives on 3.13.

Work on mypyc/mypyc#1056.
  • Loading branch information
JukkaL committed Jul 14, 2024
commit 58f65c2d6f800407db0a6dff50a7dee54733b90e
12 changes: 10 additions & 2 deletions mypyc/lib-rt/dict_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 78,11 @@ PyObject *CPyDict_SetDefault(PyObject *dict, PyObject *key, PyObject *value) {
return ret;
}
_Py_IDENTIFIER(setdefault);
return _PyObject_CallMethodIdObjArgs(dict, &PyId_setdefault, key, value, NULL);
PyObject *name = _PyUnicode_FromId(&PyId_setdefault); /* borrowed */
if (name == NULL) {
return NULL;
}
return PyObject_CallMethodObjArgs(dict, name, key, value, NULL);
}

PyObject *CPyDict_SetDefaultWithNone(PyObject *dict, PyObject *key) {
Expand Down Expand Up @@ -133,7 137,11 @@ static inline int CPy_ObjectToStatus(PyObject *obj) {

static int CPyDict_UpdateGeneral(PyObject *dict, PyObject *stuff) {
_Py_IDENTIFIER(update);
PyObject *res = _PyObject_CallMethodIdOneArg(dict, &PyId_update, stuff);
PyObject *name = _PyUnicode_FromId(&PyId_update); /* borrowed */
if (name == NULL) {
return -1;
}
PyObject *res = _PyObject_CallMethodOneArg(dict, name, stuff);
return CPy_ObjectToStatus(res);
}

Expand Down
Loading