MCPcopy Index your code
hub / github.com/RustPython/RustPython / forget

Function forget

Lib/test/support/import_helper.py:39–52  ·  view source on GitHub ↗

Forget' a module was ever imported. This removes the module from sys.modules and deletes any PEP 3147/488 or legacy .pyc files.

(modname)

Source from the content-addressed store, hash-verified

37
38
39def forget(modname):
40 """'Forget' a module was ever imported.
41
42 This removes the module from sys.modules and deletes any PEP 3147/488 or
43 legacy .pyc files.
44 """
45 unload(modname)
46 for dirname in sys.path:
47 source = os.path.join(dirname, modname + '.py')
48 # It doesn't matter if they exist or not, unlink all possible
49 # combinations of PEP 3147/488 and legacy pyc files.
50 unlink(source + 'c')
51 for opt in ('', 1, 2):
52 unlink(importlib.util.cache_from_source(source, optimization=opt))
53
54
55def make_legacy_pyc(source):

Callers 15

_check_moduleMethod · 0.90
_check_packageMethod · 0.90
test_run_nameMethod · 0.90
test_with_extensionMethod · 0.90
_cleanMethod · 0.90
test_missing_sourceMethod · 0.90
_initMethod · 0.85
py_newMethod · 0.85
create_mmap_windowsMethod · 0.85
map_immutableMethod · 0.85
mapMethod · 0.85
mapMethod · 0.85

Calls 3

unloadFunction · 0.85
unlinkFunction · 0.85
joinMethod · 0.45

Tested by 5

_check_moduleMethod · 0.72
_check_packageMethod · 0.72
test_run_nameMethod · 0.72
test_with_extensionMethod · 0.72
test_missing_sourceMethod · 0.72