mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #26367: Have importlib.__init__() raise RuntimeError when
'level' is specified but no __package__. This brings the function inline with builtins.__import__(). Thanks to Manuel Jacob for the patch.
This commit is contained in:
parent
e10d370a92
commit
4f38cb41fe
4 changed files with 381 additions and 371 deletions
|
@ -922,7 +922,7 @@ def _sanity_check(name, package, level):
|
|||
raise TypeError('module name must be str, not {}'.format(type(name)))
|
||||
if level < 0:
|
||||
raise ValueError('level must be >= 0')
|
||||
if package:
|
||||
if level > 0:
|
||||
if not isinstance(package, str):
|
||||
raise TypeError('__package__ not set to a string')
|
||||
elif package not in sys.modules:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue