New submission from Oren Milman: The following code causes an assertion failure: import os os.__name__ = None os.does_not_exist
this is because module_getattro() (in Objects/moduleobject.c) assumes that __name__ is a string, and passes it to PyErr_Format(), which asserts it is a string. if we fixed that one (so that the code above would raise an AttributeError), the following code would still cause an assertion failure: import os os.__name__ = None from os import does_not_exist this is because import_from() (in Python/ceval.c) also assumes that __name__ is a string, and passes it to PyUnicode_FromFormat(), which asserts it is a string. BTW, while we are in module_getattro(): isn't the second call to PyErr_Clear() redundant? (Ethan, IIUC, you worked on this as part of #8297 some years ago..) ---------- components: Extension Modules messages: 302348 nosy: Oren Milman, ethan.furman priority: normal severity: normal status: open title: assertion failures in case a module has a bad __name__ attribute type: crash versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31492> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com