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 imp.create_dynamic(), when spec.name is not a string #75496
Comments
The following code causes an assertion failure in get_encoded_name(), which is import imp
class BadSpec:
name = 42
origin = 'foo'
imp.create_dynamic(BadSpec()) this is because _PyImport_LoadDynamicModuleWithSpec() assumes that spec.name is should we fix this (even though imp is deprecated)? |
I'm about to go on vacation so I might not be right of mind to comment, but I think throwing a TypeError is valid if it's triggering an assertion error that is already there. P.S. Thanks for all the fuzz testing you're doing, Oren! |
do you mean that we should fix it to raise a TypeError? the assertion is there, but not explicitly. so i get:
>>> import imp
>>>
>>> class BadSpec:
... name = 42
... origin = 'foo'
...
>>> imp.create_dynamic(BadSpec())
Assertion failed: PyUnicode_Check(op), file ..\Objects\unicodeobject.c, line 380 |
Yes, I'm saying that instead of hitting the C-level assertion error an explicit TypeError should be raised (or some other change like calling str() on the object). Either way, a C-level assertion from valid Python code is bad. :) |
On Thu, Aug 31, 2017 at 1:32 PM, Brett Cannon <report@bugs.python.org> wrote:
+1
Also a big +1. :) |
Thank you Oren! |
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: