annotate Lib/imp.py @ 80272:ec00f8570c55

Merge typo fix.
author Ezio Melotti <ezio.melotti@gmail.com>
date Mon, 05 Nov 2012 22:23:16 +0200
parents 9ba57938f54d
children d5aa922f97f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
76331
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
1 """This module provides the components needed to build your own __import__
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
2 function. Undocumented functions are obsolete.
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
3
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
4 In most cases it is preferred you consider using the importlib module's
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
5 functionality over this module.
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
6
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
7 """
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
8 # (Probably) need to stay in _imp
76640
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
9 from _imp import (lock_held, acquire_lock, release_lock,
76336
60acd04d5613 Consider load_dynamic() something to keep in _imp.
Brett Cannon <brett@python.org>
parents: 76331
diff changeset
10 load_dynamic, get_frozen_object, is_frozen_package,
60acd04d5613 Consider load_dynamic() something to keep in _imp.
Brett Cannon <brett@python.org>
parents: 76331
diff changeset
11 init_builtin, init_frozen, is_builtin, is_frozen,
78486
1db6553f3f8c Issue #15576: Allow extension modules to be a package's __init__
Brett Cannon <brett@python.org>
parents: 78078
diff changeset
12 _fix_co_filename)
76331
d777f854a66e Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
Brett Cannon <brett@python.org>
parents:
diff changeset
13
78042
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
14 # Directly exposed by this module
76753
59b8a7fcb047 Properly mark names in importlib._bootstrap as private.
Brett Cannon <brett@python.org>
parents: 76642
diff changeset
15 from importlib._bootstrap import new_module
78078
9e164b404983 Issues #15169, #14599: Make PyImport_ExecCodeModuleWithPathnames() use
Brett Cannon <brett@python.org>
parents: 78042
diff changeset
16 from importlib._bootstrap import cache_from_source, source_from_cache
76338
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
17
78042
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
18
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
19 from importlib import _bootstrap
76874
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
20 from importlib import machinery
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
21 import os
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
22 import sys
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
23 import tokenize
76874
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
24 import warnings
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
25
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
26
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
27 # DEPRECATED
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
28 SEARCH_ERROR = 0
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
29 PY_SOURCE = 1
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
30 PY_COMPILED = 2
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
31 C_EXTENSION = 3
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
32 PY_RESOURCE = 4
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
33 PKG_DIRECTORY = 5
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
34 C_BUILTIN = 6
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
35 PY_FROZEN = 7
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
36 PY_CODERESOURCE = 8
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
37 IMP_HOOK = 9
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
38
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
39
78042
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
40 def get_magic():
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
41 """Return the magic number for .pyc or .pyo files."""
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
42 return _bootstrap._MAGIC_BYTES
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
43
efb5e6ab10f4 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Brett Cannon <brett@python.org>
parents: 78026
diff changeset
44
77917
b36bed82c9d0 Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Brett Cannon <brett@python.org>
parents: 77456
diff changeset
45 def get_tag():
b36bed82c9d0 Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Brett Cannon <brett@python.org>
parents: 77456
diff changeset
46 """Return the magic tag for .pyc or .pyo files."""
b36bed82c9d0 Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Brett Cannon <brett@python.org>
parents: 77456
diff changeset
47 return sys.implementation.cache_tag
b36bed82c9d0 Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Brett Cannon <brett@python.org>
parents: 77456
diff changeset
48
b36bed82c9d0 Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Brett Cannon <brett@python.org>
parents: 77456
diff changeset
49
76754
257cbd2fac38 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76753
diff changeset
50 def get_suffixes():
76874
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
51 warnings.warn('imp.get_suffixes() is deprecated; use the constants '
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
52 'defined on importlib.machinery instead',
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
53 DeprecationWarning, 2)
78486
1db6553f3f8c Issue #15576: Allow extension modules to be a package's __init__
Brett Cannon <brett@python.org>
parents: 78078
diff changeset
54 extensions = [(s, 'rb', C_EXTENSION) for s in machinery.EXTENSION_SUFFIXES]
76874
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
55 source = [(s, 'U', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
56 bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES]
76754
257cbd2fac38 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76753
diff changeset
57
257cbd2fac38 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76753
diff changeset
58 return extensions + source + bytecode
257cbd2fac38 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76753
diff changeset
59
257cbd2fac38 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76753
diff changeset
60
76633
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
61 class NullImporter:
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
62
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
63 """Null import object."""
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
64
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
65 def __init__(self, path):
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
66 if path == '':
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
67 raise ImportError('empty pathname', path='')
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
68 elif os.path.isdir(path):
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
69 raise ImportError('existing directory', path=path)
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
70
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
71 def find_module(self, fullname):
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
72 """Always returns None."""
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
73 return None
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
74
eb5c5c23ca9b Issue #13959: Re-implement imp.NullImporter in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76548
diff changeset
75
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
76 class _HackedGetData:
76371
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
77
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
78 """Compatibiilty support for 'file' arguments of various load_*()
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
79 functions."""
76371
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
80
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
81 def __init__(self, fullname, path, file=None):
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
82 super().__init__(fullname, path)
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
83 self.file = file
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
84
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
85 def get_data(self, path):
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
86 """Gross hack to contort loader to deal w/ load_*()'s bad API."""
76478
1da623513b26 Issue #14605: Expose importlib.abc.FileLoader and
Brett Cannon <brett@python.org>
parents: 76456
diff changeset
87 if self.file and path == self.path:
76371
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
88 with self.file:
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
89 # Technically should be returning bytes, but
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
90 # SourceLoader.get_code() just passed what is returned to
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
91 # compile() which can handle str. And converting to bytes would
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
92 # require figuring out the encoding to decode to and
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
93 # tokenize.detect_encoding() only accepts bytes.
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
94 return self.file.read()
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
95 else:
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
96 return super().get_data(path)
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
97
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
98
76478
1da623513b26 Issue #14605: Expose importlib.abc.FileLoader and
Brett Cannon <brett@python.org>
parents: 76456
diff changeset
99 class _LoadSourceCompatibility(_HackedGetData, _bootstrap.SourceFileLoader):
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
100
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
101 """Compatibility support for implementing load_source()."""
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
102
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
103
76371
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
104 def load_source(name, pathname, file=None):
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
105 msg = ('imp.load_source() is deprecated; use '
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
106 'importlib.machinery.SourceFileLoader(name, pathname).load_module()'
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
107 ' instead')
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
108 warnings.warn(msg, DeprecationWarning, 2)
76371
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
109 return _LoadSourceCompatibility(name, pathname, file).load_module(name)
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
110
3b5b4b4bb43c Issue #13959: Re-implement imp.load_source() in imp.py.
Brett Cannon <brett@python.org>
parents: 76368
diff changeset
111
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
112 class _LoadCompiledCompatibility(_HackedGetData,
76548
a2cf07135e4f Issue #14605: Rename _SourcelessFileLoader to SourcelessFileLoader.
Marc-Andre Lemburg <mal@egenix.com>
parents: 76547
diff changeset
113 _bootstrap.SourcelessFileLoader):
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
114
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
115 """Compatibility support for implementing load_compiled()."""
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
116
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
117
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
118 def load_compiled(name, pathname, file=None):
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
119 msg = ('imp.load_compiled() is deprecated; use '
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
120 'importlib.machinery.SourcelessFileLoader(name, pathname).'
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
121 'load_module() instead ')
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
122 warnings.warn(msg, DeprecationWarning, 2)
76381
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
123 return _LoadCompiledCompatibility(name, pathname, file).load_module(name)
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
124
66bd85bcf916 Issue #13959: Re-implement imp.load_compiled() in imp.py.
Brett Cannon <brett@python.org>
parents: 76372
diff changeset
125
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
126 def load_package(name, path):
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
127 msg = ('imp.load_package() is deprecated; use either '
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
128 'importlib.machinery.SourceFileLoader() or '
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
129 'importlib.machinery.SourcelessFileLoader() instead')
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
130 warnings.warn(msg, DeprecationWarning, 2)
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
131 if os.path.isdir(path):
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
132 extensions = (machinery.SOURCE_SUFFIXES[:] +
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
133 machinery.BYTECODE_SUFFIXES[:])
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
134 for extension in extensions:
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
135 path = os.path.join(path, '__init__'+extension)
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
136 if os.path.exists(path):
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
137 break
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
138 else:
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
139 raise ValueError('{!r} is not a package'.format(path))
76478
1da623513b26 Issue #14605: Expose importlib.abc.FileLoader and
Brett Cannon <brett@python.org>
parents: 76456
diff changeset
140 return _bootstrap.SourceFileLoader(name, path).load_module(name)
76342
4256df44023b Issue #13959: Re-implement imp.load_package() in imp.py.
Brett Cannon <brett@python.org>
parents: 76338
diff changeset
141
76338
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
142
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
143 def load_module(name, file, filename, details):
77456
034c814eb187 Issue #13959: Add to imp.find_module() and load_module's docstrings
Brett Cannon <brett@python.org>
parents: 76877
diff changeset
144 """**DEPRECATED**
034c814eb187 Issue #13959: Add to imp.find_module() and load_module's docstrings
Brett Cannon <brett@python.org>
parents: 76877
diff changeset
145
034c814eb187 Issue #13959: Add to imp.find_module() and load_module's docstrings
Brett Cannon <brett@python.org>
parents: 76877
diff changeset
146 Load a module, given information returned by find_module().
76338
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
147
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
148 The module name must include the full package name, if any.
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
149
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
150 """
2df37938b8e1 Issue #13959: Re-implement imp.load_module() in imp.py.
Brett Cannon <brett@python.org>
parents: 76336
diff changeset
151 suffix, mode, type_ = details
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
152 with warnings.catch_warnings():
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
153 warnings.simplefilter('ignore')
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
154 if mode and (not mode.startswith(('r', 'U')) or '+' in mode):
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
155 raise ValueError('invalid file open mode {!r}'.format(mode))
78816
9ba57938f54d Issue #15828: Restore support for C extension modules in imp.load_module()
Nick Coghlan <ncoghlan@gmail.com>
parents: 78486
diff changeset
156 elif file is None and type_ in {PY_SOURCE, PY_COMPILED, C_EXTENSION}:
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
157 msg = 'file object required for import (type code {})'.format(type_)
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
158 raise ValueError(msg)
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
159 elif type_ == PY_SOURCE:
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
160 return load_source(name, filename, file)
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
161 elif type_ == PY_COMPILED:
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
162 return load_compiled(name, filename, file)
78816
9ba57938f54d Issue #15828: Restore support for C extension modules in imp.load_module()
Nick Coghlan <ncoghlan@gmail.com>
parents: 78486
diff changeset
163 elif type_ == C_EXTENSION:
9ba57938f54d Issue #15828: Restore support for C extension modules in imp.load_module()
Nick Coghlan <ncoghlan@gmail.com>
parents: 78486
diff changeset
164 return load_dynamic(name, filename, file)
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
165 elif type_ == PKG_DIRECTORY:
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
166 return load_package(name, filename)
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
167 elif type_ == C_BUILTIN:
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
168 return init_builtin(name)
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
169 elif type_ == PY_FROZEN:
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
170 return init_frozen(name)
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
171 else:
78816
9ba57938f54d Issue #15828: Restore support for C extension modules in imp.load_module()
Nick Coghlan <ncoghlan@gmail.com>
parents: 78486
diff changeset
172 msg = "Don't know how to import {} (type code {})".format(name, type_)
76877
626d5c6fbd95 Issue #13959: Have
Brett Cannon <brett@python.org>
parents: 76874
diff changeset
173 raise ImportError(msg, name=name)
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
174
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
175
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
176 def find_module(name, path=None):
77456
034c814eb187 Issue #13959: Add to imp.find_module() and load_module's docstrings
Brett Cannon <brett@python.org>
parents: 76877
diff changeset
177 """**DEPRECATED**
034c814eb187 Issue #13959: Add to imp.find_module() and load_module's docstrings
Brett Cannon <brett@python.org>
parents: 76877
diff changeset
178
034c814eb187 Issue #13959: Add to imp.find_module() and load_module's docstrings
Brett Cannon <brett@python.org>
parents: 76877
diff changeset
179 Search for a module.
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
180
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
181 If path is omitted or None, search for a built-in, frozen or special
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
182 module and continue search in sys.path. The module name cannot
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
183 contain '.'; to search for a submodule of a package, pass the
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
184 submodule name and the package's __path__.
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
185
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
186 """
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
187 if not isinstance(name, str):
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
188 raise TypeError("'name' must be a str, not {}".format(type(name)))
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
189 elif not isinstance(path, (type(None), list)):
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
190 # Backwards-compatibility
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
191 raise RuntimeError("'list' must be None or a list, "
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
192 "not {}".format(type(name)))
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
193
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
194 if path is None:
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
195 if is_builtin(name):
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
196 return None, None, ('', '', C_BUILTIN)
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
197 elif is_frozen(name):
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
198 return None, None, ('', '', PY_FROZEN)
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
199 else:
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
200 path = sys.path
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
201
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
202 for entry in path:
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
203 package_directory = os.path.join(entry, name)
76874
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
204 for suffix in ['.py', machinery.BYTECODE_SUFFIXES[0]]:
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
205 package_file_name = '__init__' + suffix
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
206 file_path = os.path.join(package_directory, package_file_name)
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
207 if os.path.isfile(file_path):
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
208 return None, package_directory, ('', '', PKG_DIRECTORY)
76874
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
209 with warnings.catch_warnings():
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
210 warnings.simplefilter('ignore')
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
211 for suffix, mode, type_ in get_suffixes():
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
212 file_name = name + suffix
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
213 file_path = os.path.join(entry, file_name)
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
214 if os.path.isfile(file_path):
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
215 break
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
216 else:
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
217 continue
b81ddaf0db47 Issue #13959: Deprecate imp.get_suffixes() for new attributes on
Brett Cannon <brett@python.org>
parents: 76769
diff changeset
218 break # Break out of outer loop when breaking out of inner loop.
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
219 else:
78025
75831951a6b5 Issue #15256: Re-use the ImportError exception message as defined by
Brett Cannon <brett@python.org>
parents: 77917
diff changeset
220 raise ImportError(_bootstrap._ERR_MSG.format(name), name=name)
76455
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
221
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
222 encoding = None
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
223 if mode == 'U':
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
224 with open(file_path, 'rb') as file:
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
225 encoding = tokenize.detect_encoding(file.readline)[0]
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
226 file = open(file_path, mode, encoding=encoding)
085cf1480cfe Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76453
diff changeset
227 return file, file_path, (suffix, mode, type_)
76640
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
228
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
229
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
230 _RELOADING = {}
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
231
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
232 def reload(module):
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
233 """Reload the module and return it.
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
234
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
235 The module must have been successfully imported before.
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
236
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
237 """
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
238 if not module or type(module) != type(sys):
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
239 raise TypeError("reload() argument must be module")
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
240 name = module.__name__
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
241 if name not in sys.modules:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
242 msg = "module {} not in sys.modules"
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
243 raise ImportError(msg.format(name), name=name)
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
244 if name in _RELOADING:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
245 return _RELOADING[name]
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
246 _RELOADING[name] = module
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
247 try:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
248 parent_name = name.rpartition('.')[0]
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
249 if parent_name and parent_name not in sys.modules:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
250 msg = "parent {!r} not in sys.modules"
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
251 raise ImportError(msg.format(parentname), name=parent_name)
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
252 return module.__loader__.load_module(name)
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
253 finally:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
254 try:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
255 del _RELOADING[name]
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
256 except KeyError:
eb68502731dd Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents: 76633
diff changeset
257 pass