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

Function abs_paths

Lib/site.py:113–133  ·  view source on GitHub ↗

Set all module __file__ and __cached__ attributes to an absolute path

()

Source from the content-addressed store, hash-verified

111
112
113def abs_paths():
114 """Set all module __file__ and __cached__ attributes to an absolute path"""
115 for m in set(sys.modules.values()):
116 loader_module = None
117 try:
118 loader_module = m.__loader__.__module__
119 except AttributeError:
120 try:
121 loader_module = m.__spec__.loader.__module__
122 except AttributeError:
123 pass
124 if loader_module not in {'_frozen_importlib', '_frozen_importlib_external'}:
125 continue # don't mess with a PEP 302-supplied __file__
126 try:
127 m.__file__ = os.path.abspath(m.__file__)
128 except (AttributeError, OSError, TypeError):
129 pass
130 try:
131 m.__cached__ = os.path.abspath(m.__cached__)
132 except (AttributeError, OSError, TypeError):
133 pass
134
135
136def removeduppaths():

Callers 1

mainFunction · 0.85

Calls 2

setFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected