mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
dict_get(): Fixed a couple of stupid mistakes which caused crashes.
Also got rid of some unnecessary code.
This commit is contained in:
parent
9e63faaa66
commit
320ac331d1
1 changed files with 2 additions and 8 deletions
|
@ -958,19 +958,13 @@ dict_get(mp, args)
|
|||
PyObject *args;
|
||||
{
|
||||
PyObject *key;
|
||||
PyObject *failobj = NULL;
|
||||
PyObject *failobj = Py_None;
|
||||
PyObject *val = NULL;
|
||||
long hash;
|
||||
|
||||
if (mp->ma_table == NULL)
|
||||
goto finally;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O", &key, &failobj))
|
||||
return NULL;
|
||||
|
||||
if (failobj == NULL)
|
||||
failobj = Py_None;
|
||||
|
||||
#ifdef CACHE_HASH
|
||||
if (!PyString_Check(key) ||
|
||||
(hash = ((PyStringObject *) key)->ob_shash) == -1)
|
||||
|
@ -981,7 +975,7 @@ dict_get(mp, args)
|
|||
return NULL;
|
||||
}
|
||||
val = lookdict(mp, key, hash)->me_value;
|
||||
finally:
|
||||
|
||||
if (val == NULL)
|
||||
val = failobj;
|
||||
Py_INCREF(val);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue