Skip to content

Commit e27c2ab

Browse files
committed
[mypyc] Replace deprecated _PyDict_GetItemStringWithError
1 parent 0c10dc3 commit e27c2ab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

mypyc/lib-rt/getargs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
250250
current_arg = PyTuple_GET_ITEM(args, i);
251251
}
252252
else if (nkwargs && i >= pos) {
253-
current_arg = _PyDict_GetItemStringWithError(kwargs, kwlist[i]);
254-
if (current_arg) {
253+
int res = PyDict_GetItemStringRef(kwargs, kwlist[i], &current_arg);
254+
if (res == 1) {
255255
--nkwargs;
256256
}
257-
else if (PyErr_Occurred()) {
257+
else if (res == -1) {
258258
return 0;
259259
}
260260
}
@@ -370,8 +370,8 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
370370
Py_ssize_t j;
371371
/* make sure there are no arguments given by name and position */
372372
for (i = pos; i < bound_pos_args && i < len; i++) {
373-
current_arg = _PyDict_GetItemStringWithError(kwargs, kwlist[i]);
374-
if (unlikely(current_arg != NULL)) {
373+
int res = PyDict_GetItemStringRef(kwargs, kwlist[i], &current_arg);
374+
if (unlikely(res == 0)) {
375375
/* arg present in tuple and in dict */
376376
PyErr_Format(PyExc_TypeError,
377377
"argument for %.200s%s given by name ('%s') "
@@ -381,7 +381,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
381381
kwlist[i], i+1);
382382
goto latefail;
383383
}
384-
else if (unlikely(PyErr_Occurred() != NULL)) {
384+
else if (unlikely(res == -1)) {
385385
goto latefail;
386386
}
387387
}

0 commit comments

Comments
 (0)