diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-04-25 14:35:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 14:35:14 (GMT) |
commit | 54d068adfbf2b822bcbf90dac9b3f6684cec0f99 (patch) | |
tree | c39e59e1b4d10a1a46bb3e241cccbcbfc235d2d0 /Lib/test/libregrtest | |
parent | 93d280141c369fd1906569ff605148b6e22f6a43 (diff) | |
download | cpython-54d068adfbf2b822bcbf90dac9b3f6684cec0f99.zip cpython-54d068adfbf2b822bcbf90dac9b3f6684cec0f99.tar.gz cpython-54d068adfbf2b822bcbf90dac9b3f6684cec0f99.tar.bz2 |
gh-91904: Fix setting envvar PYTHONREGRTEST_UNICODE_GUARD (GH-91905)
It always failed on non-UTF-8 locale and prevented running regrtests.
Diffstat (limited to 'Lib/test/libregrtest')
-rw-r--r-- | Lib/test/libregrtest/setup.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py index 4ffd154..cfc1b82 100644 --- a/Lib/test/libregrtest/setup.py +++ b/Lib/test/libregrtest/setup.py @@ -5,6 +5,7 @@ import signal import sys import unittest from test import support +from test.support.os_helper import TESTFN_UNDECODABLE, FS_NONASCII try: import gc except ImportError: @@ -104,10 +105,10 @@ def setup_tests(ns): # Ensure there's a non-ASCII character in env vars at all times to force # tests consider this case. See BPO-44647 for details. - os.environ.setdefault( - UNICODE_GUARD_ENV, - "\N{SMILING FACE WITH SUNGLASSES}", - ) + if TESTFN_UNDECODABLE and os.supports_bytes_environ: + os.environb.setdefault(UNICODE_GUARD_ENV.encode(), TESTFN_UNDECODABLE) + elif FS_NONASCII: + os.environ.setdefault(UNICODE_GUARD_ENV, FS_NONASCII) def replace_stdout(): |