Commit 2ad17e19 authored by Raymond Hettinger's avatar Raymond Hettinger

Issue 10221: Improve error message for dict.pop().

parent cbba8d4c
...@@ -10,6 +10,9 @@ What's New in Python 2.7.1? ...@@ -10,6 +10,9 @@ What's New in Python 2.7.1?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #10221: dict.pop(k) now has a key error message that includes the
missing key (same message d[k] returns for missing keys).
- Issue #10125: Don't segfault when the iterator passed to ``file.writelines()`` - Issue #10125: Don't segfault when the iterator passed to ``file.writelines()``
closes the file. closes the file.
......
...@@ -1980,8 +1980,7 @@ dict_pop(PyDictObject *mp, PyObject *args) ...@@ -1980,8 +1980,7 @@ dict_pop(PyDictObject *mp, PyObject *args)
Py_INCREF(deflt); Py_INCREF(deflt);
return deflt; return deflt;
} }
PyErr_SetString(PyExc_KeyError, set_key_error(key);
"pop(): dictionary is empty");
return NULL; return NULL;
} }
if (!PyString_CheckExact(key) || if (!PyString_CheckExact(key) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment