From 77c263fcdb3330980580017f80f8cf7dbfa339ec Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Mon, 28 Oct 2024 05:25:38 -0300 Subject: [PATCH] Update pydevd --- plugins/org.python.pydev.core/pysrc/pydevd.py | 12 +--- .../pysrc/pydevd_file_utils.py | 69 ++++++++----------- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/plugins/org.python.pydev.core/pysrc/pydevd.py b/plugins/org.python.pydev.core/pysrc/pydevd.py index 7757582bbc..ed7d8dc2a0 100644 --- a/plugins/org.python.pydev.core/pysrc/pydevd.py +++ b/plugins/org.python.pydev.core/pysrc/pydevd.py @@ -123,7 +123,7 @@ get_abs_path_real_path_and_base_from_file, NORM_PATHS_AND_BASE_CONTAINER, ) -from pydevd_file_utils import get_fullname, get_package_dir, is_pydevd_path +from pydevd_file_utils import get_fullname, get_package_dir from os.path import abspath as os_path_abspath import pydevd_tracing from _pydevd_bundle.pydevd_comm import InternalThreadCommand, InternalThreadCommandForAnyThread, create_server_socket, FSNotifyThread @@ -173,7 +173,7 @@ if USE_CUSTOM_SYS_CURRENT_FRAMES_MAP: from _pydevd_bundle.pydevd_constants import constructed_tid_to_last_frame -__version_info__ = (3, 2, 1) +__version_info__ = (3, 2, 2) __version_info_str__ = [] for v in __version_info__: __version_info_str__.append(str(v)) @@ -1079,13 +1079,7 @@ def get_file_type(self, frame, abs_real_path_and_basename=None, _cache_file_type # Consider it an untraceable file unless there's no back frame (ignoring # internal files and runpy.py). - if ( - frame.f_back is not None - and self.get_file_type(frame.f_back) == self.PYDEV_FILE - # TODO: This `is_pydevd_path` is actually a workaround for debugpy - # (don't fully understand why, so, this needs more investigation). - and is_pydevd_path(frame.f_back.f_code.co_filename) - ): + if frame.f_back is not None and self.get_file_type(frame.f_back) == self.PYDEV_FILE: # Special case, this is a string coming from pydevd itself. However we have to skip this logic for other # files that are also marked as PYDEV_FILE (like external files marked this way) return self.PYDEV_FILE diff --git a/plugins/org.python.pydev.core/pysrc/pydevd_file_utils.py b/plugins/org.python.pydev.core/pysrc/pydevd_file_utils.py index 1bb6a16f35..b9fbe4d26e 100644 --- a/plugins/org.python.pydev.core/pysrc/pydevd_file_utils.py +++ b/plugins/org.python.pydev.core/pysrc/pydevd_file_utils.py @@ -1,44 +1,44 @@ r""" - This module provides utilities to get the absolute filenames so that we can be sure that: - - The case of a file will match the actual file in the filesystem (otherwise breakpoints won't be hit). - - Providing means for the user to make path conversions when doing a remote debugging session in - one machine and debugging in another. +This module provides utilities to get the absolute filenames so that we can be sure that: + - The case of a file will match the actual file in the filesystem (otherwise breakpoints won't be hit). + - Providing means for the user to make path conversions when doing a remote debugging session in + one machine and debugging in another. - To do that, the PATHS_FROM_ECLIPSE_TO_PYTHON constant must be filled with the appropriate paths. +To do that, the PATHS_FROM_ECLIPSE_TO_PYTHON constant must be filled with the appropriate paths. - @note: - in this context, the server is where your python process is running - and the client is where eclipse is running. +@note: + in this context, the server is where your python process is running + and the client is where eclipse is running. - E.g.: - If the server (your python process) has the structure - /user/projects/my_project/src/package/module1.py +E.g.: + If the server (your python process) has the structure + /user/projects/my_project/src/package/module1.py - and the client has: - c:\my_project\src\package\module1.py + and the client has: + c:\my_project\src\package\module1.py - the PATHS_FROM_ECLIPSE_TO_PYTHON would have to be: - PATHS_FROM_ECLIPSE_TO_PYTHON = [(r'c:\my_project\src', r'/user/projects/my_project/src')] + the PATHS_FROM_ECLIPSE_TO_PYTHON would have to be: + PATHS_FROM_ECLIPSE_TO_PYTHON = [(r'c:\my_project\src', r'/user/projects/my_project/src')] - alternatively, this can be set with an environment variable from the command line: - set PATHS_FROM_ECLIPSE_TO_PYTHON=[['c:\my_project\src','/user/projects/my_project/src']] + alternatively, this can be set with an environment variable from the command line: + set PATHS_FROM_ECLIPSE_TO_PYTHON=[['c:\my_project\src','/user/projects/my_project/src']] - @note: DEBUG_CLIENT_SERVER_TRANSLATION can be set to True to debug the result of those translations +@note: DEBUG_CLIENT_SERVER_TRANSLATION can be set to True to debug the result of those translations - @note: the case of the paths is important! Note that this can be tricky to get right when one machine - uses a case-independent filesystem and the other uses a case-dependent filesystem (if the system being - debugged is case-independent, 'normcase()' should be used on the paths defined in PATHS_FROM_ECLIPSE_TO_PYTHON). +@note: the case of the paths is important! Note that this can be tricky to get right when one machine +uses a case-independent filesystem and the other uses a case-dependent filesystem (if the system being +debugged is case-independent, 'normcase()' should be used on the paths defined in PATHS_FROM_ECLIPSE_TO_PYTHON). - @note: all the paths with breakpoints must be translated (otherwise they won't be found in the server) +@note: all the paths with breakpoints must be translated (otherwise they won't be found in the server) - @note: to enable remote debugging in the target machine (pydev extensions in the eclipse installation) - import pydevd;pydevd.settrace(host, stdoutToServer, stderrToServer, port, suspend) +@note: to enable remote debugging in the target machine (pydev extensions in the eclipse installation) + import pydevd;pydevd.settrace(host, stdoutToServer, stderrToServer, port, suspend) - see parameter docs on pydevd.py + see parameter docs on pydevd.py - @note: for doing a remote debugging session, all the pydevd_ files must be on the server accessible - through the PYTHONPATH (and the PATHS_FROM_ECLIPSE_TO_PYTHON only needs to be set on the target - machine for the paths that'll actually have breakpoints). +@note: for doing a remote debugging session, all the pydevd_ files must be on the server accessible + through the PYTHONPATH (and the PATHS_FROM_ECLIPSE_TO_PYTHON only needs to be set on the target + machine for the paths that'll actually have breakpoints). """ from _pydev_bundle import pydev_log @@ -963,16 +963,3 @@ def get_package_dir(mod_name): if os.path.isdir(mod_path): return mod_path return None - - -PYDEVD_ROOT_PATH = get_abs_path_real_path_and_base_from_file(os.path.dirname(__file__))[1] - - -def is_pydevd_path(path, _cache={}) -> bool: - try: - return _cache[path] - except KeyError: - # Return true if this file is rooted in the pydevd directory. - f: str = get_abs_path_real_path_and_base_from_file(path)[1] - b = _cache[path] = f.startswith(PYDEVD_ROOT_PATH) - return b