mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
This commit is contained in:
parent
a180b007d9
commit
a24107b04c
31 changed files with 538 additions and 242 deletions
|
@ -792,16 +792,17 @@ static PyObject *
|
|||
module_dir(PyObject *self, PyObject *args)
|
||||
{
|
||||
_Py_IDENTIFIER(__dict__);
|
||||
_Py_IDENTIFIER(__dir__);
|
||||
PyObject *result = NULL;
|
||||
PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
|
||||
|
||||
if (dict != NULL) {
|
||||
if (PyDict_Check(dict)) {
|
||||
PyObject *dirfunc = PyDict_GetItemString(dict, "__dir__");
|
||||
PyObject *dirfunc = _PyDict_GetItemIdWithError(dict, &PyId___dir__);
|
||||
if (dirfunc) {
|
||||
result = _PyObject_CallNoArg(dirfunc);
|
||||
}
|
||||
else {
|
||||
else if (!PyErr_Occurred()) {
|
||||
result = PyDict_Keys(dict);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue