MCPcopy Index your code
hub / github.com/python/cpython / _conditional_import_module

Method _conditional_import_module

Lib/test/test_hashlib.py:118–129  ·  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

116 _warn_on_extension_import = (os.name == 'posix' or support.Py_DEBUG)
117
118 def _conditional_import_module(self, module_name):
119 """Import a module and return a reference to it or None on failure."""
120 try:
121 return importlib.import_module(module_name)
122 except ModuleNotFoundError as error:
123 if self._warn_on_extension_import and module_name in builtin_hashes:
124 logging.getLogger(__name__).warning(
125 'Did a C extension fail to compile? %s',
126 error,
127 exc_info=error,
128 )
129 return None
130
131 def __init__(self, *args, **kwargs):
132 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