MCPcopy Index your code
hub / github.com/RustPython/RustPython / _conditional_import_module

Method _conditional_import_module

Lib/test/test_hashlib.py:111–122  ·  view source on GitHub ↗

Import a module and return a reference to it or None on failure.

(self, module_name)

Source from the content-addressed store, hash-verified

109 _warn_on_extension_import = (os.name == 'posix' or support.Py_DEBUG)
110
111 def _conditional_import_module(self, module_name):
112 """Import a module and return a reference to it or None on failure."""
113 try:
114 return importlib.import_module(module_name)
115 except ModuleNotFoundError as error:
116 if self._warn_on_extension_import and module_name in builtin_hashes:
117 logging.getLogger(__name__).warning(
118 'Did a C extension fail to compile? %s',
119 error,
120 exc_info=error,
121 )
122 return None
123
124 def __init__(self, *args, **kwargs):
125 algorithms = set()

Callers 1

__init__Method · 0.95

Calls 3

getLoggerMethod · 0.80
import_moduleMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected