Skip to content

Commit 76d0e93

Browse files
committed
Closes #28059: Fixes test_platform to set PYTHONPATH for .pyd files
1 parent 830a26b commit 76d0e93

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Lib/test/test_platform.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ def test_architecture(self):
1515

1616
@support.skip_unless_symlink
1717
def test_architecture_via_symlink(self): # issue3762
18-
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
19-
# to add the directory to the path.
18+
# On Windows, the EXE needs to know where pythonXY.dll and *.pyd is at
19+
# so we add the directory to the path and PYTHONPATH.
2020
if sys.platform == "win32":
21+
def restore_environ(old_env):
22+
os.environ.clear()
23+
os.environ.update(old_env)
24+
25+
self.addCleanup(restore_environ, dict(os.environ))
26+
2127
os.environ["Path"] = "{};{}".format(
2228
os.path.dirname(sys.executable), os.environ["Path"])
29+
os.environ["PYTHONPATH"] = os.path.dirname(sys.executable)
2330

2431
def get(python):
2532
cmd = [python, '-c',

0 commit comments

Comments
 (0)