MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / pkgutil_get_importer

Function pkgutil_get_importer

_pydevd_bundle/pydevd_runpy.py:35–56  ·  view source on GitHub ↗

Retrieve a finder for the given path item The returned finder is cached in sys.path_importer_cache if it was newly created by a path hook. The cache (or part of it) can be cleared manually if a rescan of sys.path_hooks is necessary.

(path_item)

Source from the content-addressed store, hash-verified

33# create a copy of the function we need to properly ignore this exception when
34# running the program.
35def pkgutil_get_importer(path_item):
36 """Retrieve a finder for the given path item
37
38 The returned finder is cached in sys.path_importer_cache
39 if it was newly created by a path hook.
40
41 The cache (or part of it) can be cleared manually if a
42 rescan of sys.path_hooks is necessary.
43 """
44 try:
45 importer = sys.path_importer_cache[path_item]
46 except KeyError:
47 for path_hook in sys.path_hooks:
48 try:
49 importer = path_hook(path_item)
50 sys.path_importer_cache.setdefault(path_item, importer)
51 break
52 except ImportError:
53 pass
54 else:
55 importer = None
56 return importer
57
58
59class _TempModule(object):

Callers 1

run_pathFunction · 0.85

Calls 1

setdefaultMethod · 0.80

Tested by

no test coverage detected