|
28 | 28 | # import collections.abc # not present on Py2.7 |
29 | 29 | import re |
30 | 30 | import subprocess |
31 | | -import imp |
32 | 31 | import time |
33 | 32 | try: |
34 | 33 | import sysconfig |
@@ -341,37 +340,6 @@ def rmtree(path): |
341 | 340 | if error.errno != errno.ENOENT: |
342 | 341 | raise |
343 | 342 |
|
344 | | -def make_legacy_pyc(source): |
345 | | - """Move a PEP 3147 pyc/pyo file to its legacy pyc/pyo location. |
346 | | -
|
347 | | - The choice of .pyc or .pyo extension is done based on the __debug__ flag |
348 | | - value. |
349 | | -
|
350 | | - :param source: The file system path to the source file. The source file |
351 | | - does not need to exist, however the PEP 3147 pyc file must exist. |
352 | | - :return: The file system path to the legacy pyc file. |
353 | | - """ |
354 | | - pyc_file = imp.cache_from_source(source) |
355 | | - up_one = os.path.dirname(os.path.abspath(source)) |
356 | | - legacy_pyc = os.path.join(up_one, source + ('c' if __debug__ else 'o')) |
357 | | - os.rename(pyc_file, legacy_pyc) |
358 | | - return legacy_pyc |
359 | | - |
360 | | -def forget(modname): |
361 | | - """'Forget' a module was ever imported. |
362 | | -
|
363 | | - This removes the module from sys.modules and deletes any PEP 3147 or |
364 | | - legacy .pyc and .pyo files. |
365 | | - """ |
366 | | - unload(modname) |
367 | | - for dirname in sys.path: |
368 | | - source = os.path.join(dirname, modname + '.py') |
369 | | - # It doesn't matter if they exist or not, unlink all possible |
370 | | - # combinations of PEP 3147 and legacy pyc and pyo files. |
371 | | - unlink(source + 'c') |
372 | | - unlink(source + 'o') |
373 | | - unlink(imp.cache_from_source(source, debug_override=True)) |
374 | | - unlink(imp.cache_from_source(source, debug_override=False)) |
375 | 343 |
|
376 | 344 | # On some platforms, should not run gui test even if it is allowed |
377 | 345 | # in `use_resources'. |
|
0 commit comments