Skip to content

Commit 25249d9

Browse files
committed
Removed flawed logic to check for file inside debugger as it didn't work when pydevd was installed in site-packages.
1 parent 358fdc1 commit 25249d9

File tree

2 files changed

+30
-49
lines changed

2 files changed

+30
-49
lines changed

pydevd.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
get_abs_path_real_path_and_base_from_file,
124124
NORM_PATHS_AND_BASE_CONTAINER,
125125
)
126-
from pydevd_file_utils import get_fullname, get_package_dir, is_pydevd_path
126+
from pydevd_file_utils import get_fullname, get_package_dir
127127
from os.path import abspath as os_path_abspath
128128
import pydevd_tracing
129129
from _pydevd_bundle.pydevd_comm import InternalThreadCommand, InternalThreadCommandForAnyThread, create_server_socket, FSNotifyThread
@@ -1079,13 +1079,7 @@ def get_file_type(self, frame, abs_real_path_and_basename=None, _cache_file_type
10791079

10801080
# Consider it an untraceable file unless there's no back frame (ignoring
10811081
# internal files and runpy.py).
1082-
if (
1083-
frame.f_back is not None
1084-
and self.get_file_type(frame.f_back) == self.PYDEV_FILE
1085-
# TODO: This `is_pydevd_path` is actually a workaround for debugpy
1086-
# (don't fully understand why, so, this needs more investigation).
1087-
and is_pydevd_path(frame.f_back.f_code.co_filename)
1088-
):
1082+
if frame.f_back is not None and self.get_file_type(frame.f_back) == self.PYDEV_FILE:
10891083
# Special case, this is a string coming from pydevd itself. However we have to skip this logic for other
10901084
# files that are also marked as PYDEV_FILE (like external files marked this way)
10911085
return self.PYDEV_FILE

pydevd_file_utils.py

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
r"""
2-
This module provides utilities to get the absolute filenames so that we can be sure that:
3-
- The case of a file will match the actual file in the filesystem (otherwise breakpoints won't be hit).
4-
- Providing means for the user to make path conversions when doing a remote debugging session in
5-
one machine and debugging in another.
2+
This module provides utilities to get the absolute filenames so that we can be sure that:
3+
- The case of a file will match the actual file in the filesystem (otherwise breakpoints won't be hit).
4+
- Providing means for the user to make path conversions when doing a remote debugging session in
5+
one machine and debugging in another.
66
7-
To do that, the PATHS_FROM_ECLIPSE_TO_PYTHON constant must be filled with the appropriate paths.
7+
To do that, the PATHS_FROM_ECLIPSE_TO_PYTHON constant must be filled with the appropriate paths.
88
9-
@note:
10-
in this context, the server is where your python process is running
11-
and the client is where eclipse is running.
9+
@note:
10+
in this context, the server is where your python process is running
11+
and the client is where eclipse is running.
1212
13-
E.g.:
14-
If the server (your python process) has the structure
15-
/user/projects/my_project/src/package/module1.py
13+
E.g.:
14+
If the server (your python process) has the structure
15+
/user/projects/my_project/src/package/module1.py
1616
17-
and the client has:
18-
c:\my_project\src\package\module1.py
17+
and the client has:
18+
c:\my_project\src\package\module1.py
1919
20-
the PATHS_FROM_ECLIPSE_TO_PYTHON would have to be:
21-
PATHS_FROM_ECLIPSE_TO_PYTHON = [(r'c:\my_project\src', r'/user/projects/my_project/src')]
20+
the PATHS_FROM_ECLIPSE_TO_PYTHON would have to be:
21+
PATHS_FROM_ECLIPSE_TO_PYTHON = [(r'c:\my_project\src', r'/user/projects/my_project/src')]
2222
23-
alternatively, this can be set with an environment variable from the command line:
24-
set PATHS_FROM_ECLIPSE_TO_PYTHON=[['c:\my_project\src','/user/projects/my_project/src']]
23+
alternatively, this can be set with an environment variable from the command line:
24+
set PATHS_FROM_ECLIPSE_TO_PYTHON=[['c:\my_project\src','/user/projects/my_project/src']]
2525
26-
@note: DEBUG_CLIENT_SERVER_TRANSLATION can be set to True to debug the result of those translations
26+
@note: DEBUG_CLIENT_SERVER_TRANSLATION can be set to True to debug the result of those translations
2727
28-
@note: the case of the paths is important! Note that this can be tricky to get right when one machine
29-
uses a case-independent filesystem and the other uses a case-dependent filesystem (if the system being
30-
debugged is case-independent, 'normcase()' should be used on the paths defined in PATHS_FROM_ECLIPSE_TO_PYTHON).
28+
@note: the case of the paths is important! Note that this can be tricky to get right when one machine
29+
uses a case-independent filesystem and the other uses a case-dependent filesystem (if the system being
30+
debugged is case-independent, 'normcase()' should be used on the paths defined in PATHS_FROM_ECLIPSE_TO_PYTHON).
3131
32-
@note: all the paths with breakpoints must be translated (otherwise they won't be found in the server)
32+
@note: all the paths with breakpoints must be translated (otherwise they won't be found in the server)
3333
34-
@note: to enable remote debugging in the target machine (pydev extensions in the eclipse installation)
35-
import pydevd;pydevd.settrace(host, stdoutToServer, stderrToServer, port, suspend)
34+
@note: to enable remote debugging in the target machine (pydev extensions in the eclipse installation)
35+
import pydevd;pydevd.settrace(host, stdoutToServer, stderrToServer, port, suspend)
3636
37-
see parameter docs on pydevd.py
37+
see parameter docs on pydevd.py
3838
39-
@note: for doing a remote debugging session, all the pydevd_ files must be on the server accessible
40-
through the PYTHONPATH (and the PATHS_FROM_ECLIPSE_TO_PYTHON only needs to be set on the target
41-
machine for the paths that'll actually have breakpoints).
39+
@note: for doing a remote debugging session, all the pydevd_ files must be on the server accessible
40+
through the PYTHONPATH (and the PATHS_FROM_ECLIPSE_TO_PYTHON only needs to be set on the target
41+
machine for the paths that'll actually have breakpoints).
4242
"""
4343

4444
from _pydev_bundle import pydev_log
@@ -963,16 +963,3 @@ def get_package_dir(mod_name):
963963
if os.path.isdir(mod_path):
964964
return mod_path
965965
return None
966-
967-
968-
PYDEVD_ROOT_PATH = get_abs_path_real_path_and_base_from_file(os.path.dirname(__file__))[1]
969-
970-
971-
def is_pydevd_path(path, _cache={}) -> bool:
972-
try:
973-
return _cache[path]
974-
except KeyError:
975-
# Return true if this file is rooted in the pydevd directory.
976-
f: str = get_abs_path_real_path_and_base_from_file(path)[1]
977-
b = _cache[path] = f.startswith(PYDEVD_ROOT_PATH)
978-
return b

0 commit comments

Comments
 (0)