diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-04-25 08:03:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 08:03:47 -0700 |
commit | 971343eb569a3418aa9a0bad9b638cccf1470ef8 (patch) | |
tree | 3559ca92e4ee828f10518a71a0a96617240630f8 | |
parent | dc31334ab1b43225b65358fa361b46c22918b400 (diff) | |
download | cpython-git-971343eb569a3418aa9a0bad9b638cccf1470ef8.tar.gz |
gh-91904: Fix setting envvar PYTHONREGRTEST_UNICODE_GUARD (GH-91905)
It always failed on non-UTF-8 locale and prevented running regrtests.
(cherry picked from commit 54d068adfbf2b822bcbf90dac9b3f6684cec0f99)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r-- | Lib/test/libregrtest/setup.py | 9 | ||||
-rw-r--r-- | Lib/test/test_regrtest.py | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2022-04-25-11-16-36.gh-issue-91904.13Uvrz.rst | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py index b79175944d..0bfd644bb3 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: @@ -105,10 +106,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(): diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 3780feeda3..62e6c28280 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -1303,7 +1303,7 @@ class ArgsTestCase(BaseTestCase): def test_unicode_guard_env(self): guard = os.environ.get(setup.UNICODE_GUARD_ENV) self.assertIsNotNone(guard, f"{setup.UNICODE_GUARD_ENV} not set") - if guard != "\N{SMILING FACE WITH SUNGLASSES}": + if guard.isascii(): # Skip to signify that the env var value was changed by the user; # possibly to something ASCII to work around Unicode issues. self.skipTest("Modified guard") diff --git a/Misc/NEWS.d/next/Tests/2022-04-25-11-16-36.gh-issue-91904.13Uvrz.rst b/Misc/NEWS.d/next/Tests/2022-04-25-11-16-36.gh-issue-91904.13Uvrz.rst new file mode 100644 index 0000000000..31ddfc3128 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-04-25-11-16-36.gh-issue-91904.13Uvrz.rst @@ -0,0 +1,2 @@ +Fix initialization of :envvar:`PYTHONREGRTEST_UNICODE_GUARD` which prevented +running regression tests on non-UTF-8 locale. |