Skip to content

Commit 0985fd1

Browse files
committed
simplify the defdict_missing function
1 parent 5a5f522 commit 0985fd1

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

Modules/_collectionsmodule.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,11 +2237,7 @@ defdict_missing(PyObject *op, PyObject *key)
22372237
PyObject *value;
22382238
if (factory == NULL || factory == Py_None) {
22392239
/* XXX Call dict.__missing__(key) */
2240-
PyObject *tup;
2241-
tup = PyTuple_Pack(1, key);
2242-
if (!tup) return NULL;
2243-
PyErr_SetObject(PyExc_KeyError, tup);
2244-
Py_DECREF(tup);
2240+
_PyErr_SetKeyError(key);
22452241
return NULL;
22462242
}
22472243
value = _PyObject_CallNoArgs(factory);

0 commit comments

Comments
 (0)