summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-10-30 08:10:29 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-10-30 08:10:29 (GMT)
commitdd4215483f369f17e15804179212493c76b7bc41 (patch)
treec95c589f9f2296fc8e3b6494f66f374cfbf320ba
parent6b6dffdc73848aa05045b50fe4102216622a286e (diff)
downloadcpython-dd4215483f369f17e15804179212493c76b7bc41.zip
cpython-dd4215483f369f17e15804179212493c76b7bc41.tar.gz
cpython-dd4215483f369f17e15804179212493c76b7bc41.tar.bz2
Issue 10221: Improve error message for dict.pop().
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/dictobject.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index b1e701d..52fecdd 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index d932ba7..1015772 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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) ||