@@ -250,13 +250,12 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
250
250
current_arg = Py_NewRef (PyTuple_GET_ITEM (args , i ));
251
251
}
252
252
else if (nkwargs && i >= pos ) {
253
- int res = PyDict_GetItemStringRef (kwargs , kwlist [i ], & current_arg );
254
- if (res == 1 ) {
255
- -- nkwargs ;
256
- }
257
- else if (res == -1 ) {
253
+ if (unlikely (PyDict_GetItemStringRef (kwargs , kwlist [i ], & current_arg ) < 0 )) {
258
254
return 0 ;
259
255
}
256
+ if (current_arg ) {
257
+ -- nkwargs ;
258
+ }
260
259
}
261
260
else {
262
261
current_arg = NULL ;
@@ -371,11 +370,12 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
371
370
Py_ssize_t j ;
372
371
/* make sure there are no arguments given by name and position */
373
372
for (i = pos ; i < bound_pos_args && i < len ; i ++ ) {
374
- int res = PyDict_GetItemStringRef ( kwargs , kwlist [ i ], & current_arg ) ;
375
- if (res == 1 ) {
376
- Py_DECREF ( current_arg ) ;
373
+ PyObject * current_arg ;
374
+ if (unlikely ( PyDict_GetItemStringRef ( kwargs , kwlist [ i ], & current_arg ) < 0 ) ) {
375
+ goto latefail ;
377
376
}
378
- else if (unlikely (res == 0 )) {
377
+ if (unlikely (current_arg != NULL )) {
378
+ Py_DECREF (current_arg );
379
379
/* arg present in tuple and in dict */
380
380
PyErr_Format (PyExc_TypeError ,
381
381
"argument for %.200s%s given by name ('%s') "
@@ -385,9 +385,6 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
385
385
kwlist [i ], i + 1 );
386
386
goto latefail ;
387
387
}
388
- else if (unlikely (res == -1 )) {
389
- goto latefail ;
390
- }
391
388
}
392
389
/* make sure there are no extraneous keyword arguments */
393
390
j = 0 ;
0 commit comments