]> granicus.if.org Git - python/commitdiff
Issue 10221: Improve error message for dict.pop().
authorRaymond Hettinger <python@rcn.com>
Sat, 30 Oct 2010 08:17:46 +0000 (08:17 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 30 Oct 2010 08:17:46 +0000 (08:17 +0000)
Misc/NEWS
Objects/dictobject.c

index eeff4a77607a10ff3b8affcd12d9ef7234994bf1..dc5dca453fbd334bfe6154b16c9e73c203982294 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 2.7.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 #10125: Don't segfault when the iterator passed to ``file.writelines()``
   closes the file.
 
index def3da9af0ee4a23d7f693066e00a2af077b1f76..3670e974ad0472c7eb60d94bb2beae0c6af8527f 100644 (file)
@@ -1980,8 +1980,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 (!PyString_CheckExact(key) ||