Skip to content

Commit 64f67cb

Browse files
vstinnertaegyunkim
authored andcommitted
pythongh-133711: Log Windows OEM code page in test.pythoninfo (python#134840)
Add _winapi.GetOEMCP() function.
1 parent a1446d1 commit 64f67cb

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

Lib/test/pythoninfo.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,17 @@ def collect_windows(info_add):
920920

921921
try:
922922
import _winapi
923-
dll_path = _winapi.GetModuleFileName(sys.dllhandle)
924-
info_add('windows.dll_path', dll_path)
925-
except (ImportError, AttributeError):
923+
except ImportError:
926924
pass
925+
else:
926+
try:
927+
dll_path = _winapi.GetModuleFileName(sys.dllhandle)
928+
info_add('windows.dll_path', dll_path)
929+
except AttributeError:
930+
pass
931+
932+
call_func(info_add, 'windows.ansi_code_page', _winapi, 'GetACP')
933+
call_func(info_add, 'windows.oem_code_page', _winapi, 'GetOEMCP')
927934

928935
# windows.version_caption: "wmic os get Caption,Version /value" command
929936
import subprocess

Modules/_winapi.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,19 @@ _winapi_GetACP_impl(PyObject *module)
27472747
return PyLong_FromUnsignedLong(GetACP());
27482748
}
27492749

2750+
/*[clinic input]
2751+
_winapi.GetOEMCP
2752+
2753+
Get the current Windows ANSI code page identifier.
2754+
[clinic start generated code]*/
2755+
2756+
static PyObject *
2757+
_winapi_GetOEMCP_impl(PyObject *module)
2758+
/*[clinic end generated code: output=4def5b07a8be1b3b input=e8caf4353a28e28e]*/
2759+
{
2760+
return PyLong_FromUnsignedLong(GetOEMCP());
2761+
}
2762+
27502763
/*[clinic input]
27512764
_winapi.GetFileType -> DWORD
27522765
@@ -3007,6 +3020,7 @@ static PyMethodDef winapi_functions[] = {
30073020
_WINAPI_WAITFORSINGLEOBJECT_METHODDEF
30083021
_WINAPI_WRITEFILE_METHODDEF
30093022
_WINAPI_GETACP_METHODDEF
3023+
_WINAPI_GETOEMCP_METHODDEF
30103024
_WINAPI_GETFILETYPE_METHODDEF
30113025
_WINAPI__MIMETYPES_READ_WINDOWS_REGISTRY_METHODDEF
30123026
_WINAPI_NEEDCURRENTDIRECTORYFOREXEPATH_METHODDEF

Modules/clinic/_winapi.c.h

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)