MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / run

Method run

pydevd.py:2589–2705  ·  view source on GitHub ↗
(self, file, globals=None, locals=None, is_module=False, set_trace=True)

Source from the content-addressed store, hash-verified

2587 patch_thread_modules()
2588
2589 def run(self, file, globals=None, locals=None, is_module=False, set_trace=True):
2590 module_name = None
2591 entry_point_fn = ""
2592 if is_module:
2593 # When launching with `python -m <module>`, python automatically adds
2594 # an empty path to the PYTHONPATH which resolves files in the current
2595 # directory, so, depending how pydevd itself is launched, we may need
2596 # to manually add such an entry to properly resolve modules in the
2597 # current directory (see: https://github.com/Microsoft/ptvsd/issues/1010).
2598 if "" not in sys.path:
2599 sys.path.insert(0, "")
2600 file, _, entry_point_fn = file.partition(":")
2601 module_name = file
2602 filename = get_fullname(file)
2603 if filename is None:
2604 mod_dir = get_package_dir(module_name)
2605 if mod_dir is None:
2606 sys.stderr.write("No module named %s\n" % file)
2607 return
2608 else:
2609 filename = get_fullname("%s.__main__" % module_name)
2610 if filename is None:
2611 sys.stderr.write("No module named %s\n" % file)
2612 return
2613 else:
2614 file = filename
2615 else:
2616 file = filename
2617 mod_dir = os.path.dirname(filename)
2618 main_py = os.path.join(mod_dir, "__main__.py")
2619 main_pyc = os.path.join(mod_dir, "__main__.pyc")
2620 if filename.endswith("__init__.pyc"):
2621 if os.path.exists(main_pyc):
2622 filename = main_pyc
2623 elif os.path.exists(main_py):
2624 filename = main_py
2625 elif filename.endswith("__init__.py"):
2626 if os.path.exists(main_pyc) and not os.path.exists(main_py):
2627 filename = main_pyc
2628 elif os.path.exists(main_py):
2629 filename = main_py
2630
2631 sys.argv[0] = filename
2632
2633 if os.path.isdir(file):
2634 new_target = os.path.join(file, "__main__.py")
2635 if os.path.isfile(new_target):
2636 file = new_target
2637
2638 m = None
2639 if globals is None:
2640 m = save_main_module(file, "pydevd")
2641 globals = m.__dict__
2642 try:
2643 globals["__builtins__"] = __builtins__
2644 except NameError:
2645 pass # Not there on Jython...
2646

Callers 2

mainFunction · 0.95
connectMethod · 0.45

Calls 15

wait_for_ready_to_runMethod · 0.95
prepare_to_runMethod · 0.95
init_gui_supportMethod · 0.95
notify_thread_createdMethod · 0.95
enable_tracingMethod · 0.95
_execMethod · 0.95
get_fullnameFunction · 0.90
get_package_dirFunction · 0.90
save_main_moduleFunction · 0.90
get_current_thread_idFunction · 0.90
wrap_threadsFunction · 0.90
send_concurrency_messageFunction · 0.90

Tested by

no test coverage detected