OLD | NEW |
1 """A pure Python implementation of import. | 1 """A pure Python implementation of import. |
2 | 2 |
3 References on import: | 3 References on import: |
4 | 4 |
5 * Language reference | 5 * Language reference |
6 http://docs.python.org/ref/import.html | 6 http://docs.python.org/ref/import.html |
7 * __import__ function | 7 * __import__ function |
8 http://docs.python.org/lib/built-in-funcs.html | 8 http://docs.python.org/lib/built-in-funcs.html |
9 * Packages | 9 * Packages |
10 http://www.python.org/doc/essays/packages.html | 10 http://www.python.org/doc/essays/packages.html |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 import posix as _os | 86 import posix as _os |
87 except ImportError: | 87 except ImportError: |
88 try: | 88 try: |
89 import nt as _os | 89 import nt as _os |
90 except ImportError: | 90 except ImportError: |
91 try: | 91 try: |
92 import os2 as _os | 92 import os2 as _os |
93 except ImportError: | 93 except ImportError: |
94 raise ImportError('posix, nt, or os2 module required for importlib') | 94 raise ImportError('posix, nt, or os2 module required for importlib') |
95 _bootstrap._os = _os | 95 _bootstrap._os = _os |
96 import imp, sys, marshal, errno, _fileio | 96 import imp, sys, marshal, errno, _io |
97 _bootstrap.imp = imp | 97 _bootstrap.imp = imp |
98 _bootstrap.sys = sys | 98 _bootstrap.sys = sys |
99 _bootstrap.marshal = marshal | 99 _bootstrap.marshal = marshal |
100 _bootstrap.errno = errno | 100 _bootstrap.errno = errno |
101 _bootstrap._fileio = _fileio | 101 _bootstrap._io = _io |
102 import _warnings | 102 import _warnings |
103 _bootstrap._warnings = _warnings | 103 _bootstrap._warnings = _warnings |
104 | 104 |
105 | 105 |
106 from os import sep | 106 from os import sep |
107 # For os.path.join replacement; pull from Include/osdefs.h:SEP . | 107 # For os.path.join replacement; pull from Include/osdefs.h:SEP . |
108 _bootstrap.path_sep = sep | 108 _bootstrap.path_sep = sep |
109 | 109 |
110 _bootstrap._case_ok = _case_ok | 110 _bootstrap._case_ok = _case_ok |
111 marshal._w_long = _w_long | 111 marshal._w_long = _w_long |
(...skipping 19 matching lines...) Expand all Loading... |
131 raise TypeError("relative imports require the 'package' argument") | 131 raise TypeError("relative imports require the 'package' argument") |
132 for character in name: | 132 for character in name: |
133 if character != '.': | 133 if character != '.': |
134 break | 134 break |
135 level += 1 | 135 level += 1 |
136 return _bootstrap._gcd_import(name[level:], package, level) | 136 return _bootstrap._gcd_import(name[level:], package, level) |
137 | 137 |
138 | 138 |
139 # XXX This should go away once the public API is done. | 139 # XXX This should go away once the public API is done. |
140 from ._bootstrap import * | 140 from ._bootstrap import * |
OLD | NEW |