mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
bpo-30876: Relative import from unloaded package now reimports the package (#2639)
instead of failing with SystemError. Relative import from non-package now fails with ImportError rather than SystemError.
This commit is contained in:
parent
6d13b22e3a
commit
8a9cd20edc
8 changed files with 390 additions and 388 deletions
|
@ -919,10 +919,6 @@ def _sanity_check(name, package, level):
|
|||
elif not package:
|
||||
raise ImportError('attempted relative import with no known parent '
|
||||
'package')
|
||||
elif package not in sys.modules:
|
||||
msg = ('Parent module {!r} not loaded, cannot perform relative '
|
||||
'import')
|
||||
raise SystemError(msg.format(package))
|
||||
if not name and level == 0:
|
||||
raise ValueError('Empty module name')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue