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
importlib: '.submodule' is not a relative name (no leading dot) #69957
Comments
>>> import importlib.util
>>> importlib.util.resolve_name(".submodule", None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/proj/python/cpython/Lib/importlib/util.py", line 26, in resolve_name
'(no leading dot)'.format(name))
ValueError: '.submodule' is not a relative name (no leading dot) This message sounds like nonsense. Perhaps the it should say something like:
or:
|
So both proposed messages are correct depending on what you want to accomplish; it all depends on whether the leading dot was the mistake or the missing package was. And the message does make some sense if you read it more like "'.submodule' is not a relative name (drop the leading dot)". I do agree, though, it's hard to read as written. |
New changeset b3a0765671d6 by Brett Cannon in branch 'default': |
Fixed in default (left 3.5 alone since it technically isn't a bug fix but a clarification; fine if someone else wants to handle the backport). |
Thanks, the fix is fine and there is no big need to backport it. For the record, I only came across this playing with runpy. Old message: $ python3 -m .submodule
/sbin/python3: Error while finding spec for '.submodule' (<class 'ValueError'>: '.submodule' is not a relative name (no leading dot)) New message: $ ./python -m .submodule
/media/disk/home/proj/python/cpython/python: Error while finding spec for '.submodule' (<class 'ValueError'>: no package specified for '.submodule' (required for relative module names)) |
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: