Author Oren Milman
Recipients Oren Milman, ethan.furman
Date 2017-09-16.18:00:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505584845.12.0.793382405796.issue31492@psf.upfronthosting.co.za>
In-reply-to
Content
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..)
History
Date User Action Args
2017-09-16 18:00:45Oren Milmansetrecipients: + Oren Milman, ethan.furman
2017-09-16 18:00:45Oren Milmansetmessageid: <1505584845.12.0.793382405796.issue31492@psf.upfronthosting.co.za>
2017-09-16 18:00:45Oren Milmanlinkissue31492 messages
2017-09-16 18:00:44Oren Milmancreate