From 7f67090b10694657bc72f39bdeaa3b189c7be7fc Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 7 Jul 2024 23:56:33 +0200 Subject: [PATCH] Fix `_PyObject_LookupAttrId` for Python 3.13 (#17505) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_PyObject_LookupAttrId` was removed / replaced with `PyObject_GetOptionalAttrString` in https://github.com/python/cpython/pull/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) ``` --- mypyc/lib-rt/pythonsupport.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypyc/lib-rt/pythonsupport.h b/mypyc/lib-rt/pythonsupport.h index c5423ab0fab5..2d18e19b2c56 100644 --- a/mypyc/lib-rt/pythonsupport.h +++ b/mypyc/lib-rt/pythonsupport.h @@ -48,7 +48,7 @@ update_bases(PyObject *bases) } continue; } - if (_PyObject_LookupAttrId(base, &PyId___mro_entries__, &meth) < 0) { + if (PyObject_GetOptionalAttrString(base, PyId___mro_entries__.string, &meth) < 0) { goto error; } if (!meth) { @@ -374,7 +374,7 @@ _CPyDictView_New(PyObject *dict, PyTypeObject *type) static int _CPyObject_HasAttrId(PyObject *v, _Py_Identifier *name) { PyObject *tmp = NULL; - int result = _PyObject_LookupAttrId(v, name, &tmp); + int result = PyObject_GetOptionalAttrString(v, name->string, &tmp); if (tmp) { Py_DECREF(tmp); }