summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-05-14 01:00:51 (GMT)
committerGuido van Rossum <guido@python.org>1998-05-14 01:00:51 (GMT)
commit474b19e2abc71c3ae0afd5e7a11006cf40b9c047 (patch)
treea8797e14eb0d401e15d9aee0d96066b5f0ff93c1 /Objects
parent4180cf16499b3e5398e0cd9dc7b027b885a01db3 (diff)
downloadcpython-474b19e2abc71c3ae0afd5e7a11006cf40b9c047.zip
cpython-474b19e2abc71c3ae0afd5e7a11006cf40b9c047.tar.gz
cpython-474b19e2abc71c3ae0afd5e7a11006cf40b9c047.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 06d2dc4..7fed379 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;
}