use threading.__file__ als last fallback

This commit is contained in:
Tim Rid 2025-08-12 21:47:49 +02:00
parent e7bcae3ed8
commit e9785ca87c

View file

@ -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