diff options
author | Oren Milman <orenmn@gmail.com> | 2017-09-19 11:23:01 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-19 11:23:01 (GMT) |
commit | 6db7033192cd537ca987a65971acb01206c3ba82 (patch) | |
tree | f05068e6e7e700e321cd282f577570918d9c64f6 /Objects | |
parent | 453408a50508bb6801b6724ba7c7d1c017c218b6 (diff) | |
download | cpython-6db7033192cd537ca987a65971acb01206c3ba82.zip cpython-6db7033192cd537ca987a65971acb01206c3ba82.tar.gz cpython-6db7033192cd537ca987a65971acb01206c3ba82.tar.bz2 |
bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (#3620)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/moduleobject.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 2be49fb..2973263 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -687,14 +687,11 @@ module_getattro(PyModuleObject *m, PyObject *name) if (m->md_dict) { _Py_IDENTIFIER(__name__); mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); - if (mod_name) { + if (mod_name && PyUnicode_Check(mod_name)) { PyErr_Format(PyExc_AttributeError, "module '%U' has no attribute '%U'", mod_name, name); return NULL; } - else if (PyErr_Occurred()) { - PyErr_Clear(); - } } PyErr_Format(PyExc_AttributeError, "module has no attribute '%U'", name); |