From 65ca88e4e0b3d26e625d1aecd7c0fe0beb5e3b1d Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 4 Dec 2015 15:19:42 -0800 Subject: Issue #25771: Tweak ValueError message when package isn't specified for importlib.util.resolve_name() but is needed. Thanks to Martin Panter for the bug report. --- Lib/importlib/util.py | 4 ++-- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py index 1dbff26..39cb0f7 100644 --- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -22,8 +22,8 @@ def resolve_name(name, package): if not name.startswith('.'): return name elif not package: - raise ValueError('{!r} is not a relative name ' - '(no leading dot)'.format(name)) + raise ValueError(f'no package specified for {repr(name)} ' + '(required for relative module names)') level = 0 for character in name: if character != '.': diff --git a/Misc/NEWS b/Misc/NEWS index f87ed38..f4e7e54 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,9 @@ Core and Builtins Library ------- +- Issue #25771: Tweak the exception message for importlib.util.resolve_name() + when 'package' isn't specified but necessary. + - Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). -- cgit v0.12