From e9785ca87c434f59743b46cd23ad9e2ef6bca983 Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:47:49 +0200 Subject: [PATCH] use threading.__file__ als last fallback --- src/debugpy/_vendored/pydevd/pydevd_file_utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/debugpy/_vendored/pydevd/pydevd_file_utils.py b/src/debugpy/_vendored/pydevd/pydevd_file_utils.py index ab13b2bc..7ca38344 100644 --- a/src/debugpy/_vendored/pydevd/pydevd_file_utils.py +++ b/src/debugpy/_vendored/pydevd/pydevd_file_utils.py @@ -89,10 +89,13 @@ def _get_library_dir(): if library_dir is None or not os_path_exists(library_dir): if hasattr(os, "__file__"): + # "os" is a frozen import an thus "os.__file__" is not always set. + # See https://github.com/python/cpython/pull/28656 library_dir = os.path.dirname(os.__file__) - - if library_dir is None: - library_dir = "" # not possible to detect library_dir + else: + # "threading" is not a frozen import an thus "threading.__file__" is always set. + import threading + library_dir = os.path.dirname(threading.__file__) return library_dir