8000 MNT: Avoid use of deprecated _PyDict_GetItemStringWithError in f2py · numpy/numpy@93e2fd3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 93e2fd3

Browse files
ngoldbaumcharris
authored andcommitted
MNT: Avoid use of deprecated _PyDict_GetItemStringWithError in f2py
1 parent 426f3e3 commit 93e2fd3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

numpy/f2py/src/fortranobject.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ fortran_getattr(PyFortranObject *fp, char *name)
363363
{
364364
int i, j, k, flag;
365365
if (fp->dict != NULL) {
366+
// python 3.13 added PyDict_GetItemRef
367+
#if PY_VERSION_HEX < 0x030D0000
366368
PyObject *v = _PyDict_GetItemStringWithError(fp->dict, name);
367369
if (v == NULL && PyErr_Occurred()) {
368370
return NULL;
@@ -371,6 +373,17 @@ fortran_getattr(PyFortranObject *fp, char *name)
371373
Py_INCREF(v);
372374
return v;
373375
}
376+
#else
377+
PyObject *v;
378+
int result = PyDict_GetItemStringRef(fp->dict, name, &v);
379+
if (result == -1) {
380+
return NULL;
381+
}
382+
else if (result == 1) {
383+
return v;
384+
}
385+
#endif
386+
374387
}
375388
for (i = 0, j = 1; i < fp->len && (j = strcmp(name, fp->defs[i].name));
376389
i++)

0 commit comments

Comments
 (0)
0