mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[python] PY-84883 allow debugging modules with Python 3.14
- `pkgutil.get_loader()` was removed in Python 3.14 - switch to `importlib.util.find_spec()` instead (cherry picked from commit 688119f9a207eb2c204ddb89ac0770ab3d800956) IJ-MR-178861 GitOrigin-RevId: 7849bfab553c88318ee353f38c2b33224c5f4cb2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
93c4446da8
commit
f90e077c2b
@@ -611,19 +611,25 @@ def get_abs_path_real_path_and_base_from_frame(frame):
|
||||
|
||||
|
||||
def get_fullname(mod_name):
|
||||
if IS_PY3K:
|
||||
import pkgutil
|
||||
else:
|
||||
from _pydev_imps import _pydev_pkgutil_old as pkgutil
|
||||
try:
|
||||
import importlib.util
|
||||
|
||||
spec = importlib.util.find_spec(mod_name)
|
||||
if spec is not None and spec.origin is not None:
|
||||
return spec.origin
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if not IS_PY3K:
|
||||
from _pydev_imps import _pydev_pkgutil_old as pkgutil
|
||||
|
||||
loader = pkgutil.get_loader(mod_name)
|
||||
except:
|
||||
return None
|
||||
if loader is not None:
|
||||
for attr in ("get_filename", "_get_filename"):
|
||||
meth = getattr(loader, attr, None)
|
||||
if meth is not None:
|
||||
return meth(mod_name)
|
||||
if loader is not None:
|
||||
for attr in ("get_filename", "_get_filename"):
|
||||
meth = getattr(loader, attr, None)
|
||||
if meth is not None:
|
||||
return meth(mod_name)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from pydevd_file_utils import get_fullname
|
||||
|
||||
|
||||
def test_get_fullname_exists():
|
||||
assert get_fullname('pydevd_file_utils').endswith('pydevd_file_utils.py')
|
||||
|
||||
|
||||
def test_get_fullname_unknown():
|
||||
assert get_fullname("hello_world") is None
|
||||
Reference in New Issue
Block a user