From: Guido van Rossum Date: Thu, 14 May 1998 01:00:51 +0000 (+0000) Subject: Make sure that PyDict_GetItem[String]() *never* raises an exception. X-Git-Tag: v1.5.2a1~647 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=474b19e2abc71c3ae0afd5e7a11006cf40b9c047;p=thirdparty%2FPython%2Fcpython.git Make sure that PyDict_GetItem[String]() *never* raises an exception. If the argument is not a dictionary, simply return NULL. If the hash() on the key fails, clear the error. --- diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 06d2dc4f92cc..7fed379ef595 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -317,7 +317,6 @@ PyDict_GetItem(op, key) { long hash; if (!PyDict_Check(op)) { - PyErr_BadInternalCall(); return NULL; } if (((dictobject *)op)->ma_table == NULL) @@ -328,8 +327,10 @@ PyDict_GetItem(op, key) #endif { hash = PyObject_Hash(key); - if (hash == -1) + if (hash == -1) { + PyErr_Clear(); return NULL; + } } return lookdict((dictobject *)op, key, hash) -> me_value; }