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.
This commit is contained in:
Guido van Rossum 1998-05-14 01:00:51 +00:00
parent 4180cf1649
commit 474b19e2ab
1 changed files with 3 additions and 2 deletions

View File

@ -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;
}