gh-91338: Ensure test_ucnhash_capi_reset doesn't pass PYTHONHOME to _testembed.exe by neonene · Pull Request #32313 · python/cpython (original) (raw)

A minor tweak for Windows. _test_embed.exe fails to import *.pyd modules when the initialization is repeated with PYTHONHOME from python.bat.

>python.bat -m test test_embed -v

======================================================================
FAIL: test_ucnhash_capi_reset (test.test_embed.EmbeddingTests.test_ucnhash_capi_reset)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\cpython\Lib\test\test_embed.py", line 349, in test_ucnhash_capi_reset
    out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\cpython\Lib\test\test_embed.py", line 117, in run_embedded_interpreter
stdout:
9

stderr:
--- Loop #1 ---
--- Loop #2 ---
  File "<string>", line 1
    print('\N{digit nine}')
                          ^
SyntaxError: (unicode error) \N escapes not supported (can't load unicodedata module)

sys.path at Loop#1 has the build directory, which is replaced with f"{PYTHONHOME}/DLLs" at the next loop. The behavior looks realistically designed.

GitHub CI machines doesn't show the error, using rt.bat where PYTHONHOME is not set.

https://bugs.python.org/issue47182