diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-12-13 12:29:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 12:29:09 +0100 |
commit | 91106cd9ff2f321c0f60fbaa09fd46c80aa5c266 (patch) | |
tree | ff002e0532736a97f3ddd367c1491e7b04611816 /Modules/_winapi.c | |
parent | bpo-32284: Fix documentation of BinaryIO and TextIO (#4832) (diff) | |
download | cpython-91106cd9ff2f321c0f60fbaa09fd46c80aa5c266.tar.gz cpython-91106cd9ff2f321c0f60fbaa09fd46c80aa5c266.tar.bz2 cpython-91106cd9ff2f321c0f60fbaa09fd46c80aa5c266.zip |
bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)
* Add -X utf8 command line option, PYTHONUTF8 environment variable
and a new sys.flags.utf8_mode flag.
* If the LC_CTYPE locale is "C" at startup: enable automatically the
UTF-8 mode.
* Add _winapi.GetACP(). encodings._alias_mbcs() now calls
_winapi.GetACP() to get the ANSI code page
* locale.getpreferredencoding() now returns 'UTF-8' in the UTF-8
mode. As a side effect, open() now uses the UTF-8 encoding by
default in this mode.
* Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding
in the UTF-8 Mode.
* Update subprocess._args_from_interpreter_flags() to handle -X utf8
* Skip some tests relying on the current locale if the UTF-8 mode is
enabled.
* Add test_utf8mode.py.
* _Py_DecodeUTF8_surrogateescape() gets a new optional parameter to
return also the length (number of wide characters).
* pymain_get_global_config() and pymain_set_global_config() now
always copy flag values, rather than only copying if the new value
is greater than the old value.
Diffstat (limited to 'Modules/_winapi.c')
-rw-r--r-- | Modules/_winapi.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 0a1d139cd0e..604c05d4ae1 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -1490,6 +1490,20 @@ _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer, } +/*[clinic input] +_winapi.GetACP + +Get the current Windows ANSI code page identifier. +[clinic start generated code]*/ + +static PyObject * +_winapi_GetACP_impl(PyObject *module) +/*[clinic end generated code: output=f7ee24bf705dbb88 input=1433c96d03a05229]*/ +{ + return PyLong_FromUnsignedLong(GetACP()); +} + + static PyMethodDef winapi_functions[] = { _WINAPI_CLOSEHANDLE_METHODDEF _WINAPI_CONNECTNAMEDPIPE_METHODDEF @@ -1515,6 +1529,7 @@ static PyMethodDef winapi_functions[] = { _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF _WINAPI_WAITFORSINGLEOBJECT_METHODDEF _WINAPI_WRITEFILE_METHODDEF + _WINAPI_GETACP_METHODDEF {NULL, NULL} }; @@ -1595,14 +1610,14 @@ PyInit__winapi(void) WINAPI_CONSTANT(F_DWORD, WAIT_OBJECT_0); WINAPI_CONSTANT(F_DWORD, WAIT_ABANDONED_0); WINAPI_CONSTANT(F_DWORD, WAIT_TIMEOUT); - + WINAPI_CONSTANT(F_DWORD, ABOVE_NORMAL_PRIORITY_CLASS); WINAPI_CONSTANT(F_DWORD, BELOW_NORMAL_PRIORITY_CLASS); WINAPI_CONSTANT(F_DWORD, HIGH_PRIORITY_CLASS); WINAPI_CONSTANT(F_DWORD, IDLE_PRIORITY_CLASS); WINAPI_CONSTANT(F_DWORD, NORMAL_PRIORITY_CLASS); WINAPI_CONSTANT(F_DWORD, REALTIME_PRIORITY_CLASS); - + WINAPI_CONSTANT(F_DWORD, CREATE_NO_WINDOW); WINAPI_CONSTANT(F_DWORD, DETACHED_PROCESS); WINAPI_CONSTANT(F_DWORD, CREATE_DEFAULT_ERROR_MODE); |