New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertion failure in PyErr_WriteUnraisable() in case of an exception with a bad __module__ #75599
Comments
The following code causes an assertion failure in PyErr_WriteUnraisable() (in class BadException(Exception):
__module__ = None
class BadClass:
def __del__(self):
raise BadException
foo = BadClass()
del foo this is because PyErr_WriteUnraisable() assumes that __module__ is a string, what is the wanted behavior in such a case? |
Printing '<unknown>' LGTM. Implicit converting to str can raise a warning or exception if __module__ is a bytes object. |
I think this patch doesn't need a test (which would require using a subprocess). |
what do you mean by 'Implicit converting to str can raise a warning or exception if __module__ is a bytes object.'? should we treat __module__ differently in case it is a bytes object? |
PyFile_WriteObject(moduleName, f, Py_PRINT_RAW) implicitly converts its argument to string. I mean that treating non-string moduleName the same way as string moduleName not equal to string "builtins" and calling PyFile_WriteObject() would cause other problem. Treating non-string moduleName the same way as moduleName==NULL LGTM. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: