[Python-checkins] cpython: Issue #18408: Fix PyDict_GetItemString(), suppress PyUnicode_FromString() error

victor.stinner python-checkins at python.org
Tue Jul 16 23:09:18 CEST 2013


http://hg.python.org/cpython/rev/ac4e8e6a7436
changeset:   84672:ac4e8e6a7436
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jul 16 22:16:05 2013 +0200
summary:
  Issue #18408: Fix PyDict_GetItemString(), suppress PyUnicode_FromString() error

As PyDict_GetItem(), PyDict_GetItemString() suppresses all errors that may
occur for historical reasons.

files:
  Objects/dictobject.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2692,8 +2692,10 @@
 {
     PyObject *kv, *rv;
     kv = PyUnicode_FromString(key);
-    if (kv == NULL)
+    if (kv == NULL) {
+        PyErr_Clear();
         return NULL;
+    }
     rv = PyDict_GetItem(v, kv);
     Py_DECREF(kv);
     return rv;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list