Issue25771
Created on 2015-12-01 05:31 by martin.panter, last changed 2015-12-05 00:19 by martin.panter. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg255642 - (view) | Author: Martin Panter (martin.panter) * | Date: 2015-12-01 05:31 | |
>>> 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:
'.submodule' should be an absolute name (no leading dot)
or:
relative import of '.submodule' not allowed outside of a package
|
|||
| msg255654 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2015-12-01 15:42 | |
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. |
|||
| msg255895 - (view) | Author: Roundup Robot (python-dev) | Date: 2015-12-04 23:19 | |
New changeset b3a0765671d6 by Brett Cannon in branch 'default': Issue #25771: Tweak ValueError message when package isn't specified https://hg.python.org/cpython/rev/b3a0765671d6 |
|||
| msg255896 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2015-12-04 23:20 | |
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). |
|||
| msg255909 - (view) | Author: Martin Panter (martin.panter) * | Date: 2015-12-05 00:19 | |
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)) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2015-12-05 00:19:14 | martin.panter | set | messages:
+ msg255909 versions: - Python 3.4, Python 3.5 |
| 2015-12-04 23:20:54 | brett.cannon | set | status: open -> closed resolution: fixed messages: + msg255896 stage: resolved |
| 2015-12-04 23:19:53 | python-dev | set | nosy:
+ python-dev messages: + msg255895 |
| 2015-12-01 15:42:22 | brett.cannon | set | assignee: brett.cannon messages:
+ msg255654 |
| 2015-12-01 05:31:34 | martin.panter | create | |