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

Method try_import_attribute

Lib/test/test_support.py:874–886  ·  view source on GitHub ↗
(self, fullname, default=None)

Source from the content-addressed store, hash-verified

872 return contextlib.nullcontext()
873
874 def try_import_attribute(self, fullname, default=None):
875 if fullname is None:
876 return default
877 assert fullname.count('.') == 1, fullname
878 module_name, attribute = fullname.split('.', maxsplit=1)
879 try:
880 module = importlib.import_module(module_name)
881 except ImportError:
882 return default
883 try:
884 return getattr(module, attribute, default)
885 except TypeError:
886 return default
887
888 def fetch_hash_function(self, name, implementation):
889 info = hashlib_helper.get_hash_func_info(name)

Callers 1

fetch_hash_functionMethod · 0.95

Calls 3

countMethod · 0.45
splitMethod · 0.45
import_moduleMethod · 0.45

Tested by

no test coverage detected