MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / save_main_module

Function save_main_module

_pydevd_bundle/pydevd_utils.py:27–39  ·  view source on GitHub ↗
(file, module_name)

Source from the content-addressed store, hash-verified

25
26
27def save_main_module(file, module_name):
28 # patch provided by: Scott Schlesier - when script is run, it does not
29 # use globals from pydevd:
30 # This will prevent the pydevd script from contaminating the namespace for the script to be debugged
31 # pretend pydevd is not the main module, and
32 # convince the file to be debugged that it was loaded as main
33 m = sys.modules[module_name] = sys.modules["__main__"]
34 m.__name__ = module_name
35 loader = m.__loader__ if hasattr(m, "__loader__") else None
36 spec = spec_from_file_location("__main__", file, loader=loader)
37 m = module_from_spec(spec)
38 sys.modules["__main__"] = m
39 return m
40
41
42def is_current_thread_main_thread():

Callers 2

runMethod · 0.90
run_fileFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected