diff options
author | robot-contrib <robot-contrib@yandex-team.ru> | 2022-05-18 00:43:36 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.ru> | 2022-05-18 00:43:36 +0300 |
commit | 9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch) | |
tree | 78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/utils/module_paths.py | |
parent | 8113a823ffca6451bb5ff8f0334560885a939a24 (diff) | |
download | ydb-9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75.tar.gz |
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/utils/module_paths.py')
-rw-r--r-- | contrib/python/ipython/py3/IPython/utils/module_paths.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/contrib/python/ipython/py3/IPython/utils/module_paths.py b/contrib/python/ipython/py3/IPython/utils/module_paths.py index 0570c322e6a..f9f7cacc332 100644 --- a/contrib/python/ipython/py3/IPython/utils/module_paths.py +++ b/contrib/python/ipython/py3/IPython/utils/module_paths.py @@ -2,8 +2,6 @@ Utility functions for finding modules on sys.path. -`find_module` returns a path to module or None, given certain conditions. - """ #----------------------------------------------------------------------------- # Copyright (c) 2011, the IPython Development Team. @@ -20,6 +18,7 @@ Utility functions for finding modules on sys.path. # Stdlib imports import importlib import os +import sys # Third-party imports @@ -42,7 +41,7 @@ def find_mod(module_name): """ Find module `module_name` on sys.path, and return the path to module `module_name`. - - If `module_name` refers to a module directory, then return path to __init__ file. + - If `module_name` refers to a module directory, then return path to __init__ file. - If `module_name` is a directory without an __init__file, return None. - If module is missing or does not have a `.py` or `.pyw` extension, return None. - Note that we are not interested in running bytecode. @@ -51,16 +50,18 @@ def find_mod(module_name): Parameters ---------- module_name : str - + Returns ------- module_path : str Path to module `module_name`, its __init__.py, or None, depending on above conditions. """ - loader = importlib.util.find_spec(module_name) - module_path = loader.origin + spec = importlib.util.find_spec(module_name) + module_path = spec.origin if module_path is None: + if spec.loader in sys.meta_path: + return spec.loader return None else: split_path = module_path.split(".") |