Skip to content

Commit 7f67090

Browse files
authored
Fix _PyObject_LookupAttrId for Python 3.13 (#17505)
`_PyObject_LookupAttrId` was removed / replaced with `PyObject_GetOptionalAttrString` in python/cpython#106522. https://docs.python.org/dev/c-api/object.html#c.PyObject_GetOptionalAttrString Fixes ```cpp /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h: In function ‘update_bases’: (diff) /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h:51:13: error: implicit declaration of function ‘_PyObject_LookupAttrId’; did you mean ‘_PyObject_GetAttrId’? [-Werror=implicit-function-declaration] (diff) 51 | if (_PyObject_LookupAttrId(base, &PyId___mro_entries__, &meth) < 0) { (diff) | ^~~~~~~~~~~~~~~~~~~~~~ (diff) | _PyObject_GetAttrId (diff) ```
1 parent 9175ce5 commit 7f67090

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mypyc/lib-rt/pythonsupport.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ update_bases(PyObject *bases)
4848
}
4949
continue;
5050
}
51-
if (_PyObject_LookupAttrId(base, &PyId___mro_entries__, &meth) < 0) {
51+
if (PyObject_GetOptionalAttrString(base, PyId___mro_entries__.string, &meth) < 0) {
5252
goto error;
5353
}
5454
if (!meth) {
@@ -374,7 +374,7 @@ _CPyDictView_New(PyObject *dict, PyTypeObject *type)
374374
static int
375375
_CPyObject_HasAttrId(PyObject *v, _Py_Identifier *name) {
376376
PyObject *tmp = NULL;
377-
int result = _PyObject_LookupAttrId(v, name, &tmp);
377+
int result = PyObject_GetOptionalAttrString(v, name->string, &tmp);
378378
if (tmp) {
379379
Py_DECREF(tmp);
380380
}

0 commit comments

Comments
 (0)