Skip to content

Commit ed6d510

Browse files
committed
Use subrepo to link to PyDev.Debugger instead of copying it (microsoft#1714)
* Remove copy of pydevd and add subrepo script * git subrepo clone https://github.com/fabioz/PyDev.Debugger.git src/debugpy/_vendored/pydevd subrepo: subdir: "src/debugpy/_vendored/pydevd" merged: "7d6e6e68" upstream: origin: "https://github.com/fabioz/PyDev.Debugger.git" branch: "main" commit: "7d6e6e68" git-subrepo: version: "0.4.9" origin: "???" commit: "???" * Add binskim settings to match debugpy * git subrepo clone --force https://github.com/fabioz/PyDev.Debugger.git src/debugpy/_vendored/pydevd subrepo: subdir: "src/debugpy/_vendored/pydevd" merged: "cf2e47cb" upstream: origin: "https://github.com/fabioz/PyDev.Debugger.git" branch: "main" commit: "cf2e47cb" git-subrepo: version: "0.4.9" origin: "???" commit: "???" * Remove unnecessary string test by removing the lambda in pydevd_sys_monitoring * Fix linter * Put back the fix in qt_loaders * Put back binskim flag
1 parent cf2e47c commit ed6d510

File tree

10 files changed

+4457
-3077
lines changed

10 files changed

+4457
-3077
lines changed

_pydevd_bundle/pydevd_frame_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,15 @@ def short_frame(frame):
6767

6868
filename = frame.f_code.co_filename
6969
name = splitext(basename(filename))[0]
70-
return "%s::%s %s" % (name, frame.f_code.co_name, frame.f_lineno)
70+
line = hasattr(frame, "f_lineno") and frame.f_lineno or 1
71+
return "%s::%s %s" % (name, frame.f_code.co_name, line)
7172

7273

7374
def short_stack(frame):
7475
stack = []
7576
while frame:
7677
stack.append(short_frame(frame))
77-
frame = frame.f_back
78+
frame = frame.f_back if hasattr(frame, "f_back") else None
7879
return "Stack: %s\n" % (" -> ".join(stack))
7980

8081

_pydevd_sys_monitoring/_pydevd_sys_monitoring.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,41 @@ def _get_thread_info(create: bool, depth: int) -> Optional[ThreadInfo]:
451451
return _thread_local_info.thread_info
452452

453453

454-
_CodeLineInfo = namedtuple("_CodeLineInfo", "line_to_offset, first_line, last_line")
454+
# fmt: off
455+
# IFDEF CYTHON
456+
# cdef class _CodeLineInfo:
457+
# cdef dict line_to_offset
458+
# cdef int first_line
459+
# cdef int last_line
460+
# ELSE
461+
class _CodeLineInfo:
462+
line_to_offset: Dict[int, Any]
463+
first_line: int
464+
last_line: int
465+
# ENDIF
466+
# fmt: on
455467

468+
# fmt: off
469+
# IFDEF CYTHON
470+
# def __init__(self, dict line_to_offset, int first_line, int last_line):
471+
# self.line_to_offset = line_to_offset
472+
# self.first_line = first_line
473+
# self.last_line = last_line
474+
# ELSE
475+
def __init__(self, line_to_offset, first_line, last_line):
476+
self.line_to_offset = line_to_offset
477+
self.first_line = first_line
478+
self.last_line = last_line
479+
480+
# ENDIF
481+
# fmt: on
456482

457483
# Note: this method has a version in cython too
458484
# fmt: off
459485
# IFDEF CYTHON
460-
# cdef _get_code_line_info(code_obj, _cache={}):
486+
# cdef _CodeLineInfo _get_code_line_info(code_obj, _cache={}):
461487
# ELSE
462-
def _get_code_line_info(code_obj, _cache={}):
488+
def _get_code_line_info(code_obj, _cache={}) -> _CodeLineInfo:
463489
# ENDIF
464490
# fmt: on
465491
try:

_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c

Lines changed: 4373 additions & 3021 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,41 @@ cdef _get_thread_info(bint create, int depth):
457457
return _thread_local_info.thread_info
458458

459459

460-
_CodeLineInfo = namedtuple("_CodeLineInfo", "line_to_offset, first_line, last_line")
460+
# fmt: off
461+
# IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
462+
cdef class _CodeLineInfo:
463+
cdef dict line_to_offset
464+
cdef int first_line
465+
cdef int last_line
466+
# ELSE
467+
# class _CodeLineInfo:
468+
# line_to_offset: Dict[int, Any]
469+
# first_line: int
470+
# last_line: int
471+
# ENDIF
472+
# fmt: on
461473

474+
# fmt: off
475+
# IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
476+
def __init__(self, dict line_to_offset, int first_line, int last_line):
477+
self.line_to_offset = line_to_offset
478+
self.first_line = first_line
479+
self.last_line = last_line
480+
# ELSE
481+
# def __init__(self, line_to_offset, first_line, last_line):
482+
# self.line_to_offset = line_to_offset
483+
# self.first_line = first_line
484+
# self.last_line = last_line
485+
#
486+
# ENDIF
487+
# fmt: on
462488

463489
# Note: this method has a version in cython too
464490
# fmt: off
465491
# IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
466-
cdef _get_code_line_info(code_obj, _cache={}):
492+
cdef _CodeLineInfo _get_code_line_info(code_obj, _cache={}):
467493
# ELSE
468-
# def _get_code_line_info(code_obj, _cache={}):
494+
# def _get_code_line_info(code_obj, _cache={}) -> _CodeLineInfo:
469495
# ENDIF
470496
# fmt: on
471497
try:

pydev_ipython/qt_loaders.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ def has_binding(api):
143143
return check_version(mod.__version__, "1.0.3")
144144
else:
145145
return True
146+
147+
except ModuleNotFoundError:
148+
from importlib import machinery
149+
150+
# importing top level PyQt4/PySide module is ok...
151+
mod = __import__(module_name)
152+
153+
# ...importing submodules is not
154+
loader_details = (machinery.ExtensionFileLoader, machinery.EXTENSION_SUFFIXES)
155+
submod_finder = machinery.FileFinder(mod.__path__[0], loader_details)
156+
submod_check = (
157+
submod_finder.find_spec("QtCore") is not None
158+
and submod_finder.find_spec("QtGui") is not None
159+
and submod_finder.find_spec("QtSvg") is not None
160+
)
161+
162+
# we can also safely check PySide version
163+
if api == QT_API_PYSIDE:
164+
return check_version(mod.__version__, '1.0.3') and submod_check
165+
else:
166+
return submod_check
167+
146168
except ImportError:
147169
return False
148170

pydevd.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,17 +1073,6 @@ def get_file_type(self, frame, abs_real_path_and_basename=None, _cache_file_type
10731073
return _cache_file_type[cache_key]
10741074
except:
10751075
if abs_real_path_and_basename[0] == "<string>":
1076-
# TODO: This isn't ideal. We should make it so that "<string>" is
1077-
# never marked as pydevd (i.e.: investigate all the use cases
1078-
# where pydevd does this and actually mark it as "<pydevd-string>")
1079-
1080-
# Consider it an untraceable file unless there's no back frame (ignoring
1081-
# internal files and runpy.py).
1082-
if frame.f_back is not None and self.get_file_type(frame.f_back) == self.PYDEV_FILE:
1083-
# Special case, this is a string coming from pydevd itself. However we have to skip this logic for other
1084-
# files that are also marked as PYDEV_FILE (like external files marked this way)
1085-
return self.PYDEV_FILE
1086-
10871076
f = frame.f_back
10881077
while f is not None:
10891078
if self.get_file_type(f) != self.PYDEV_FILE and pydevd_file_utils.basename(f.f_code.co_filename) not in (

pydevd_attach_to_process/windows/compile_windows.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /D BITS_32 /Qspectre run_code_
1818
copy run_code_on_dllmain_x86.dll ..\run_code_on_dllmain_x86.dll /Y
1919
copy run_code_on_dllmain_x86.pdb ..\run_code_on_dllmain_x86.pdb /Y
2020

21-
cl /EHsc /Zi /O1 /W3 /Qspectre inject_dll.cpp /link /PROFILE /GUARD:CF /out:inject_dll_x86.exe
21+
cl /EHsc /Zi /O1 /W3 /Qspectre inject_dll.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:inject_dll_x86.exe
2222
copy inject_dll_x86.exe ..\inject_dll_x86.exe /Y
2323
copy inject_dll_x86.pdb ..\inject_dll_x86.pdb /Y
2424

tests_python/resources/not_my_code/_pydevd_string_breakpoint.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests_python/resources/not_my_code/main_on_entry3.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests_python/test_debugger_json.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5739,26 +5739,6 @@ def test_stop_on_entry2(case_setup_dap):
57395739
writer.finished_ok = True
57405740

57415741

5742-
def test_stop_on_entry_verify_strings(case_setup_dap):
5743-
with case_setup_dap.test_file("not_my_code/main_on_entry3.py") as writer:
5744-
json_facade = JsonFacade(writer)
5745-
json_facade.write_set_debugger_property([], ["main_on_entry3.py", "_pydevd_string_breakpoint.py"])
5746-
json_facade.write_launch(
5747-
justMyCode=True,
5748-
stopOnEntry=True,
5749-
showReturnValue=True,
5750-
rules=[
5751-
{"path": "**/main_on_entry3.py", "include": False},
5752-
{"path": "**/_pydevd_string_breakpoint.py", "include": False},
5753-
],
5754-
)
5755-
5756-
json_facade.write_make_initial_run()
5757-
json_facade.wait_for_thread_stopped("breakpoint", file="empty_file.py")
5758-
json_facade.write_continue()
5759-
writer.finished_ok = True
5760-
5761-
57625742
@pytest.mark.parametrize("val", [True, False])
57635743
def test_debug_options(case_setup_dap, val):
57645744
with case_setup_dap.test_file("_debugger_case_debug_options.py") as writer:

0 commit comments

Comments
 (0)