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

Function using___main__

Lib/test/test_crossinterp.py:349–357  ·  view source on GitHub ↗

Make sure __main__ module exists (and clean up after).

()

Source from the content-addressed store, hash-verified

347
348@contextlib.contextmanager
349def using___main__():
350 """Make sure __main__ module exists (and clean up after)."""
351 modname = '__main__'
352 if modname not in sys.modules:
353 with import_helper.isolated_modules():
354 yield import_helper.add_module(modname)
355 else:
356 with import_helper.module_restored(modname) as mod:
357 yield mod
358
359
360@contextlib.contextmanager

Calls 1

add_moduleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…