Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82f04e2

Browse files
committed
regrtest: Fix module.__path__
Issue #26538: libregrtest: Fix setup_tests() to keep module.__path__ type (_NamespacePath), don't convert to a list. Add _NamespacePath.__setitem__() method to importlib._bootstrap_external.
1 parent 6453e9e commit 82f04e2

3 files changed

Lines changed: 945 additions & 933 deletions

File tree

Lib/importlib/_bootstrap_external.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,9 @@ def _recalculate(self):
971971
def __iter__(self):
972972
return iter(self._recalculate())
973973

974+
def __setitem__(self, index, path):
975+
self._path[index] = path
976+
974977
def __len__(self):
975978
return len(self._recalculate())
976979

Lib/test/libregrtest/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def setup_tests(ns):
4141
# the packages to prevent later imports to fail when the CWD is different.
4242
for module in sys.modules.values():
4343
if hasattr(module, '__path__'):
44-
module.__path__ = [os.path.abspath(path)
45-
for path in module.__path__]
44+
for index, path in enumerate(module.__path__):
45+
module.__path__[index] = os.path.abspath(path)
4646
if hasattr(module, '__file__'):
4747
module.__file__ = os.path.abspath(module.__file__)
4848

0 commit comments

Comments
 (0)