Merged revisions 72957 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72957 | benjamin.peterson | 2009-05-26 21:43:46 -0500 (Tue, 26 May 2009) | 1 line

  correctly handle descrs with __missing__
........
This commit is contained in:
Benjamin Peterson 2009-05-27 03:08:59 +00:00
parent 499b2ee8a8
commit a720559878
2 changed files with 16 additions and 6 deletions

View file

@ -1128,13 +1128,14 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
/* Look up __missing__ method if we're a subclass. */
PyObject *missing;
static PyObject *missing_str = NULL;
if (missing_str == NULL)
missing_str =
PyUnicode_InternFromString("__missing__");
missing = _PyType_Lookup(Py_TYPE(mp), missing_str);
missing = _PyObject_LookupSpecial((PyObject *)mp,
"__missing__",
&missing_str);
if (missing != NULL)
return PyObject_CallFunctionObjArgs(missing,
(PyObject *)mp, key, NULL);
key, NULL);
else if (PyErr_Occurred())
return NULL;
}
set_key_error(key);
return NULL;