diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2012-08-31 14:13:45 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-08-31 14:13:45 (GMT) |
commit | 91b9f139bc629e1ba931c60a3301e8062f6f4e6d (patch) | |
tree | e959ba896e7fcb4c24bcafad98673c737b281369 /Lib/imp.py | |
parent | 380c55cc58911a4777f080744f596d1e96fd2357 (diff) | |
download | cpython-91b9f139bc629e1ba931c60a3301e8062f6f4e6d.zip cpython-91b9f139bc629e1ba931c60a3301e8062f6f4e6d.tar.gz cpython-91b9f139bc629e1ba931c60a3301e8062f6f4e6d.tar.bz2 |
Issue #15828: Restore support for C extension modules in imp.load_module()
Diffstat (limited to 'Lib/imp.py')
-rw-r--r-- | Lib/imp.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -153,13 +153,15 @@ def load_module(name, file, filename, details): warnings.simplefilter('ignore') if mode and (not mode.startswith(('r', 'U')) or '+' in mode): raise ValueError('invalid file open mode {!r}'.format(mode)) - elif file is None and type_ in {PY_SOURCE, PY_COMPILED}: + elif file is None and type_ in {PY_SOURCE, PY_COMPILED, C_EXTENSION}: msg = 'file object required for import (type code {})'.format(type_) raise ValueError(msg) elif type_ == PY_SOURCE: return load_source(name, filename, file) elif type_ == PY_COMPILED: return load_compiled(name, filename, file) + elif type_ == C_EXTENSION: + return load_dynamic(name, filename, file) elif type_ == PKG_DIRECTORY: return load_package(name, filename) elif type_ == C_BUILTIN: @@ -167,7 +169,7 @@ def load_module(name, file, filename, details): elif type_ == PY_FROZEN: return init_frozen(name) else: - msg = "Don't know how to import {} (type code {}".format(name, type_) + msg = "Don't know how to import {} (type code {})".format(name, type_) raise ImportError(msg, name=name) |