diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000000000..235b5b86a437be --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,28 @@ +name: Manual Windows + +on: + workflow_dispatch: + inputs: + arch: + description: CPU architecture + required: true + type: choice + options: + - x86 + - x64 + - arm64 + free-threading: + description: Whether to compile CPython in free-threading mode + required: false + type: boolean + default: false + +env: + FORCE_COLOR: 1 + +jobs: + build-windows: + uses: ./.github/workflows/reusable-windows.yml + with: + arch: ${{ inputs.arch }} + free-threading: ${{ inputs.free-threading }} diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 1b40e0d05fe3bc..92c050cb5d2c2a 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -970,12 +970,22 @@ def test_python_legacy_windows_fs_encoding(self): rc, out, err = assert_python_ok('-c', code, PYTHONLEGACYWINDOWSFSENCODING='1') self.assertIn(expected.encode(), out) - @unittest.skipUnless(support.MS_WINDOWS, 'Test only applicable on Windows') + @unittest.skipUnless(type(sys.stderr.buffer.raw).__name__ == "_WindowsConsoleIO", + "Test only applicable on Windows with console IO") def test_python_legacy_windows_stdio(self): - code = "import sys; print(sys.stdin.encoding, sys.stdout.encoding)" - expected = 'cp' - rc, out, err = assert_python_ok('-c', code, PYTHONLEGACYWINDOWSSTDIO='1') - self.assertIn(expected.encode(), out) + 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("") + + 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) @unittest.skipIf("-fsanitize" in sysconfig.get_config_vars().get('PY_CFLAGS', ()), "PYTHONMALLOCSTATS doesn't work with ASAN")