From: Raymond Hettinger Date: Sat, 30 Oct 2010 08:14:53 +0000 (+0000) Subject: Issue 10221: Improve error message for dict.pop(). X-Git-Tag: v3.1.3rc1~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7529afce3c8e0e012738c5671d583beb3b85e270;p=thirdparty%2FPython%2Fcpython.git Issue 10221: Improve error message for dict.pop(). --- diff --git a/Misc/NEWS b/Misc/NEWS index fb6814fb67ff..a1b5246f7fcb 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.1.3? 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 8d0e6a4a73e2..9c17be7a2525 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1810,8 +1810,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) ||