mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue #28026: Raise ImportError when exec_module() exists but create_module() is missing.
This commit is contained in:
parent
e58571b7ea
commit
f3fd06a2e4
4 changed files with 902 additions and 910 deletions
|
@ -559,9 +559,8 @@ def module_from_spec(spec):
|
|||
# module creation should be used.
|
||||
module = spec.loader.create_module(spec)
|
||||
elif hasattr(spec.loader, 'exec_module'):
|
||||
_warnings.warn('starting in Python 3.6, loaders defining exec_module() '
|
||||
'must also define create_module()',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
raise ImportError('loaders that define exec_module() '
|
||||
'must also define create_module()')
|
||||
if module is None:
|
||||
module = _new_module(spec.name)
|
||||
_init_module_attrs(spec, module)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue