Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue25771

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:importlib: '.submodule' is not a relative name (no leading dot)
Type:behaviorStage:resolved
Components:Versions:Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: brett.cannonNosy List: brett.cannon, martin.panter, python-dev
Priority:normalKeywords:easy

Created on2015-12-01 05:31 bymartin.panter, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Messages (5)
msg255642 -(view)Author: Martin Panter (martin.panter)*(Python committer)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)*(Python committer)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)(Python triager)Date: 2015-12-04 23:19
New changesetb3a0765671d6 by Brett Cannon in branch 'default':Issue#25771: Tweak ValueError message when package isn't specifiedhttps://hg.python.org/cpython/rev/b3a0765671d6
msg255896 -(view)Author: Brett Cannon (brett.cannon)*(Python committer)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)*(Python committer)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
DateUserActionArgs
2022-04-11 14:58:24adminsetgithub: 69957
2015-12-05 00:19:14martin.pantersetmessages: +msg255909
versions: - Python 3.4, Python 3.5
2015-12-04 23:20:54brett.cannonsetstatus: open -> closed
resolution: fixed
messages: +msg255896

stage: resolved
2015-12-04 23:19:53python-devsetnosy: +python-dev
messages: +msg255895
2015-12-01 15:42:22brett.cannonsetassignee:brett.cannon

messages: +msg255654
nosy: +brett.cannon
2015-12-01 05:31:34martin.pantercreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp