Show More
@@ -12,7 +12,10 b' import sys' | |||||
12 | # to work when run from a virtualenv. The modules were chosen empirically |
|
12 | # to work when run from a virtualenv. The modules were chosen empirically | |
13 | # so that the return value matches the return value without virtualenv. |
|
13 | # so that the return value matches the return value without virtualenv. | |
14 | if True: # disable lexical sorting checks |
|
14 | if True: # disable lexical sorting checks | |
15 | import BaseHTTPServer |
|
15 | try: | |
|
16 | import BaseHTTPServer as basehttpserver | |||
|
17 | except ImportError: | |||
|
18 | basehttpserver = None | |||
16 | import zlib |
|
19 | import zlib | |
17 |
|
20 | |||
18 | # Whitelist of modules that symbols can be directly imported from. |
|
21 | # Whitelist of modules that symbols can be directly imported from. | |
@@ -183,8 +186,9 b' def populateextmods(localmods):' | |||||
183 | def list_stdlib_modules(): |
|
186 | def list_stdlib_modules(): | |
184 | """List the modules present in the stdlib. |
|
187 | """List the modules present in the stdlib. | |
185 |
|
188 | |||
|
189 | >>> py3 = sys.version_info[0] >= 3 | |||
186 | >>> mods = set(list_stdlib_modules()) |
|
190 | >>> mods = set(list_stdlib_modules()) | |
187 | >>> 'BaseHTTPServer' in mods |
|
191 | >>> 'BaseHTTPServer' in mods or py3 | |
188 | True |
|
192 | True | |
189 |
|
193 | |||
190 | os.path isn't really a module, so it's missing: |
|
194 | os.path isn't really a module, so it's missing: | |
@@ -201,7 +205,7 b' def list_stdlib_modules():' | |||||
201 | >>> 'collections' in mods |
|
205 | >>> 'collections' in mods | |
202 | True |
|
206 | True | |
203 |
|
207 | |||
204 | >>> 'cStringIO' in mods |
|
208 | >>> 'cStringIO' in mods or py3 | |
205 | True |
|
209 | True | |
206 |
|
210 | |||
207 | >>> 'cffi' in mods |
|
211 | >>> 'cffi' in mods | |
@@ -223,7 +227,9 b' def list_stdlib_modules():' | |||||
223 | stdlib_prefixes = {sys.prefix, sys.exec_prefix} |
|
227 | stdlib_prefixes = {sys.prefix, sys.exec_prefix} | |
224 | # We need to supplement the list of prefixes for the search to work |
|
228 | # We need to supplement the list of prefixes for the search to work | |
225 | # when run from within a virtualenv. |
|
229 | # when run from within a virtualenv. | |
226 |
for mod in ( |
|
230 | for mod in (basehttpserver, zlib): | |
|
231 | if mod is None: | |||
|
232 | continue | |||
227 | try: |
|
233 | try: | |
228 | # Not all module objects have a __file__ attribute. |
|
234 | # Not all module objects have a __file__ attribute. | |
229 | filename = mod.__file__ |
|
235 | filename = mod.__file__ |
General Comments 0
You need to be logged in to leave comments.
Login now