summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-27 04:33:00 (GMT)
committerGitHub <noreply@github.com>2017-09-27 04:33:00 (GMT)
commitf0db2dfda777ad3380e7816cabe4c4240f31687f (patch)
treee0c4b32926ff2eab9ce997281840f9f70ffc6ea4 /Objects
parenta1c49f6f09150f70f063417c8d67a38e59dde7ed (diff)
downloadcpython-f0db2dfda777ad3380e7816cabe4c4240f31687f.zip
cpython-f0db2dfda777ad3380e7816cabe4c4240f31687f.tar.gz
cpython-f0db2dfda777ad3380e7816cabe4c4240f31687f.tar.bz2
[3.6] bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (GH-3620). (#3773)
(cherry picked from commit 6db7033192cd537ca987a65971acb01206c3ba82)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/moduleobject.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 79be51a..f357af2 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -667,14 +667,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);