Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0ac40c

Browse files
committed
Better error message when non-dictionary received for **kwarg
1 parent 619eea6 commit a0ac40c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Python/getargs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,8 +1023,13 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
10231023

10241024
if (keywords) {
10251025
if (!PyDict_Check(keywords)) {
1026-
PyErr_SetString(PyExc_SystemError,
1027-
"non-dictionary object received when keyword dictionary expected");
1026+
if (keywords == NULL)
1027+
PyErr_SetString(PyExc_SystemError,
1028+
"NULL received when keyword dictionary expected");
1029+
else
1030+
PyErr_Format(PyExc_SystemError,
1031+
"%s received when keyword dictionary expected",
1032+
keywords->ob_type->tp_name);
10281033
return 0;
10291034
}
10301035
kwlen = PyDict_Size(keywords);

0 commit comments

Comments
 (0)