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

This commit is contained in:
Raymond Hettinger 2010-10-30 08:10:29 +00:00
parent 6b6dffdc73
commit dd4215483f
2 changed files with 4 additions and 2 deletions

View File

@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1?
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 #5437: A preallocated MemoryError instance should not hold traceback
data (including local variables caught in the stack trace) alive infinitely.

View File

@ -1820,8 +1820,7 @@ dict_pop(PyDictObject *mp, PyObject *args)
Py_INCREF(deflt);
return deflt;
}
PyErr_SetString(PyExc_KeyError,
"pop(): dictionary is empty");
set_key_error(key);
return NULL;
}
if (!PyUnicode_CheckExact(key) ||