MCPcopy Index your code
hub / github.com/python/cpython / uncache

Function uncache

Lib/test/test_importlib/util.py:145–166  ·  view source on GitHub ↗

Uncache a module from sys.modules. A basic sanity check is performed to prevent uncaching modules that either cannot/shouldn't be uncached.

(*names)

Source from the content-addressed store, hash-verified

143
144@contextlib.contextmanager
145def uncache(*names):
146 """Uncache a module from sys.modules.
147
148 A basic sanity check is performed to prevent uncaching modules that either
149 cannot/shouldn't be uncached.
150
151 """
152 for name in names:
153 if name in ('sys', 'marshal'):
154 raise ValueError("cannot uncache {}".format(name))
155 try:
156 del sys.modules[name]
157 except KeyError:
158 pass
159 try:
160 yield
161 finally:
162 for name in names:
163 try:
164 del sys.modules[name]
165 except KeyError:
166 pass
167
168
169@contextlib.contextmanager

Calls 1

formatMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…