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

Function check

tests_python/test_bytecode_manipulation.py:70–180  ·  view source on GitHub ↗

:param has_line_event_optimized_in_original_case: If True, we're handling a case where we have a double jump, i.e.: some case where there's a JUMP_FORWARD which points to a JUMP_ABSOLUTE and this is optimized so that the JUMP_FORWARD is changed directly to a JUMP_ABSOLUT

(
    filename,
    method,
    method_kwargs=None,
    skip_breaks_at_lines=None,
    method_to_change=None,
    stop_at_all_lines=False,
    has_line_event_optimized_in_original_case=False,
)

Source from the content-addressed store, hash-verified

68
69
70def check(
71 filename,
72 method,
73 method_kwargs=None,
74 skip_breaks_at_lines=None,
75 method_to_change=None,
76 stop_at_all_lines=False,
77 has_line_event_optimized_in_original_case=False,
78):
79 """
80 :param has_line_event_optimized_in_original_case:
81 If True, we're handling a case where we have a double jump, i.e.: some case
82 where there's a JUMP_FORWARD which points to a JUMP_ABSOLUTE and this is
83 optimized so that the JUMP_FORWARD is changed directly to a JUMP_ABSOLUTE and
84 we end up skipping one line event which is supposed to be there but isn't in
85 the initial case but appears when we run after modifying the bytecode in memory.
86
87 See: https://github.com/microsoft/debugpy/issues/973#issuecomment-1178090731
88 """
89 from _pydevd_frame_eval.pydevd_modify_bytecode import _get_code_line_info
90 from _pydevd_frame_eval import pydevd_modify_bytecode
91
92 if method_to_change is None:
93 method_to_change = method
94
95 if method_kwargs is None:
96 method_kwargs = {}
97 if skip_breaks_at_lines is None:
98 skip_breaks_at_lines = set()
99
100 pydev_break_stops = []
101
102 def _pydev_needs_stop_at_break(line):
103 pydev_break_stops.append(line)
104 return False
105
106 tracer = _Tracer()
107
108 def accept_frame(f):
109 return filename in f.f_code.co_filename
110
111 code = method_to_change.__code__
112 code_line_info = _get_code_line_info(code)
113
114 try:
115 tracer.accept_frame = accept_frame
116
117 def call():
118 method(**method_kwargs)
119
120 tracer.call(call)
121 breakpoint_hit_at_least_once = False
122
123 # Ok, we just ran the tracer once without any breakpoints.
124 #
125 # Gather its tracing profile: this will be our baseline for further tests (it should contain
126 # the events and the order in which the were executed).
127 #

Callers 9

test_set_pydevd_break_01Function · 0.70
test_set_pydevd_break_02Function · 0.70
test_set_pydevd_break_03Function · 0.70
test_set_pydevd_break_04Function · 0.70
test_set_pydevd_break_05Function · 0.70
test_set_pydevd_break_06Function · 0.70
test_set_pydevd_break_07Function · 0.70
test_set_pydevd_break_08Function · 0.70

Calls 6

_get_code_line_infoFunction · 0.90
getvalueMethod · 0.80
_TracerClass · 0.70
callMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected