Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-133711: Enable UTF-8 mode by default (PEP 686) #133712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
Loading
from
Prev Previous commit
Next Next commit
Merge branch 'main' into utf-8-mode
# Conflicts:
#	Lib/test/test_cmd_line.py
  • Loading branch information
AA-Turner committed May 26, 2025
commit b56e01b643fe6bc0cf18d837618af6397cadbe6d
32 changes: 19 additions & 13 deletions 32 Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,19 +977,25 @@ def test_python_legacy_windows_fs_encoding(self):

@unittest.skipUnless(support.MS_WINDOWS, 'Test only applicable on Windows')
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
def test_python_legacy_windows_stdio(self):
def get_stderr_class(legacy_windows_stdio):
code = 'import sys; print(type(sys.stderr.buffer.raw))'
env = {'PYTHONLEGACYWINDOWSSTDIO': str(int(legacy_windows_stdio))}
# use stderr=None as legacy_windows_stdio doesn't affect pipes
p = spawn_python('-c', code, env=env, stderr=None)
out = kill_python(p).strip().decode('ascii', 'ignore')
return out.removeprefix("<class '").removesuffix("'>")

out = get_stderr_class(legacy_windows_stdio=True)
self.assertEqual('_io.FileIO', out)

out = get_stderr_class(legacy_windows_stdio=False)
self.assertEqual('_io._WindowsConsoleIO', out)
# Test that _WindowsConsoleIO is used when PYTHONLEGACYWINDOWSSTDIO
# is not set.
# We cannot use PIPE becase it prevents creating new console.
# So we use exit code.
code = "import sys; sys.exit(type(sys.stdout.buffer.raw).__name__ != '_WindowsConsoleIO')"
env = os.environ.copy()
env["PYTHONLEGACYWINDOWSSTDIO"] = ""
p = subprocess.run([sys.executable, "-c", code],
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=env)
self.assertEqual(p.returncode, 0)

# Then test that FIleIO is used when PYTHONLEGACYWINDOWSSTDIO is set.
code = "import sys; sys.exit(type(sys.stdout.buffer.raw).__name__ != 'FileIO')"
env["PYTHONLEGACYWINDOWSSTDIO"] = "1"
p = subprocess.run([sys.executable, "-c", code],
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=env)
self.assertEqual(p.returncode, 0)

@unittest.skipIf("-fsanitize" in sysconfig.get_config_vars().get('PY_CFLAGS', ()),
"PYTHONMALLOCSTATS doesn't work with ASAN")
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.