Commit 3f729691 authored by Barry Warsaw's avatar Barry Warsaw

dict_get(): Fixed a couple of stupid mistakes which caused crashes.

Also got rid of some unnecessary code.
parent 937ad0e2
...@@ -958,19 +958,13 @@ dict_get(mp, args) ...@@ -958,19 +958,13 @@ dict_get(mp, args)
PyObject *args; PyObject *args;
{ {
PyObject *key; PyObject *key;
PyObject *failobj = NULL; PyObject *failobj = Py_None;
PyObject *val = NULL; PyObject *val = NULL;
long hash; long hash;
if (mp->ma_table == NULL)
goto finally;
if (!PyArg_ParseTuple(args, "O|O", &key, &failobj)) if (!PyArg_ParseTuple(args, "O|O", &key, &failobj))
return NULL; return NULL;
if (failobj == NULL)
failobj = Py_None;
#ifdef CACHE_HASH #ifdef CACHE_HASH
if (!PyString_Check(key) || if (!PyString_Check(key) ||
(hash = ((PyStringObject *) key)->ob_shash) == -1) (hash = ((PyStringObject *) key)->ob_shash) == -1)
...@@ -981,7 +975,7 @@ dict_get(mp, args) ...@@ -981,7 +975,7 @@ dict_get(mp, args)
return NULL; return NULL;
} }
val = lookdict(mp, key, hash)->me_value; val = lookdict(mp, key, hash)->me_value;
finally:
if (val == NULL) if (val == NULL)
val = failobj; val = failobj;
Py_INCREF(val); Py_INCREF(val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment