Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList

if self.tsan:
setup_tsan_tests(self.cmdline_args)
self.want_header = True

if self.tsan_parallel:
setup_tsan_parallel_tests(self.cmdline_args)
self.want_header = True

alltests = findtests(testdir=self.test_dir,
exclude=exclude_tests)
Expand Down
34 changes: 32 additions & 2 deletions Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
import sysconfig
import tempfile
import textwrap
import types
from collections.abc import Callable
_winapi: types.ModuleType | None
try:
import _winapi
except ImportError:
_winapi = None

from test import support
from test.support import os_helper
Expand Down Expand Up @@ -636,8 +642,32 @@ def display_header(use_resources: dict[str, str | None],
if process_cpu_count and process_cpu_count != cpu_count:
cpu_count = f"{process_cpu_count} (process) / {cpu_count} (system)"
print("== CPU count:", cpu_count)
print("== encodings: locale=%s FS=%s"
% (locale.getencoding(), sys.getfilesystemencoding()))

encodings = []
if _winapi is not None:
# Log ANSI and OEM code pages
ansi = f'cp{_winapi.GetACP()}'
oem = f'cp{_winapi.GetOEMCP()}'
if ansi == oem:
encodings.append(f'ansi=oem={ansi}')
else:
encodings.append(f'ansi={ansi}')
encodings.append(f'oem={oem}')
encodings.append(f'FS={sys.getfilesystemencoding()}')
else:
locale_encoding = locale.getencoding() # nl_langinfo(CODESET)
fs_encoding = sys.getfilesystemencoding() # normalized name
if locale_encoding.lower() == fs_encoding.lower():
encodings.append(f'locale=FS={fs_encoding}')
else:
encodings.append(f'locale={locale_encoding}')
encodings.append(f'FS={fs_encoding}')
if sys.flags.utf8_mode:
encodings.append('utf8=1')
if (not sys.flags.ignore_environment
and os.environ.get('PYTHONCOERCECLOCALE') == '0'):
encodings.append('coerce=0')
print(f"== encodings: {' '.join(encodings)}")

if use_resources:
text = format_resources(use_resources)
Expand Down
14 changes: 14 additions & 0 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,19 @@ _winapi_GetACP_impl(PyObject *module)
return PyLong_FromUnsignedLong(GetACP());
}

/*[clinic input]
_winapi.GetOEMCP
Get the current Windows ANSI code page identifier.
[clinic start generated code]*/

static PyObject *
_winapi_GetOEMCP_impl(PyObject *module)
/*[clinic end generated code: output=4def5b07a8be1b3b input=e8caf4353a28e28e]*/
{
return PyLong_FromUnsignedLong(GetOEMCP());
}

/*[clinic input]
_winapi.GetFileType -> DWORD
Expand Down Expand Up @@ -3017,6 +3030,7 @@ static PyMethodDef winapi_functions[] = {
_WINAPI_WAITFORSINGLEOBJECT_METHODDEF
_WINAPI_WRITEFILE_METHODDEF
_WINAPI_GETACP_METHODDEF
_WINAPI_GETOEMCP_METHODDEF
_WINAPI_GETFILETYPE_METHODDEF
_WINAPI__MIMETYPES_READ_WINDOWS_REGISTRY_METHODDEF
_WINAPI_NEEDCURRENTDIRECTORYFOREXEPATH_METHODDEF
Expand Down
20 changes: 19 additions & 1 deletion Modules/clinic/_winapi.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading