MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / abs_paths

Function abs_paths

tools/python-3.11.9-amd64/Lib/site.py:106–126  ·  view source on GitHub ↗

Set all module __file__ and __cached__ attributes to an absolute path

()

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls 2

setFunction · 0.50
valuesMethod · 0.45

Tested by

no test coverage detected