mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (#3620)
This commit is contained in:
parent
453408a505
commit
6db7033192
4 changed files with 20 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue