cpython: faf5493e6f61 (original) (raw)
Mercurial > cpython
changeset 104386:faf5493e6f61 3.6
Issue #28333: Enables Unicode for ps1/ps2 and input() prompts. (Patch by Eryk Sun) [#28333]
Steve Dower steve.dower@microsoft.com | |
---|---|
date | Sat, 08 Oct 2016 12🔞16 -0700 |
parents | e6ec01903f6c |
children | cb62e921bd06 63ceadf8410f |
files | Misc/NEWS Parser/myreadline.c |
diffstat | 2 files changed, 26 insertions(+), 4 deletions(-)[+] [-] Misc/NEWS 2 Parser/myreadline.c 28 |
line wrap: on
line diff
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -213,6 +213,8 @@ Library Windows ------- +- Issue #28333: Enables Unicode for ps1/ps2 and input() prompts +
- Issue #28251: Improvements to help manuals on Windows.
- Issue #28110: launcher.msi has different product codes between 32-bit and
--- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -203,17 +203,37 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE #ifdef MS_WINDOWS if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) {
HANDLE hStdIn;[](#l2.7)
HANDLE hStdIn, hStdErr;[](#l2.8)
_Py_BEGIN_SUPPRESS_IPH hStdIn = (HANDLE)_get_osfhandle(fileno(sys_stdin));
hStdErr = (HANDLE)_get_osfhandle(fileno(stderr));[](#l2.12) _Py_END_SUPPRESS_IPH[](#l2.13)
if (_get_console_type(hStdIn) == 'r') { fflush(sys_stdout);
if (prompt)[](#l2.17)
fprintf(stderr, "%s", prompt);[](#l2.18)
fflush(stderr);[](#l2.19)
if (prompt) {[](#l2.20)
if (_get_console_type(hStdErr) == 'w') {[](#l2.21)
wchar_t *wbuf;[](#l2.22)
int wlen;[](#l2.23)
wlen = MultiByteToWideChar(CP_UTF8, 0, prompt, -1,[](#l2.24)
NULL, 0);[](#l2.25)
if (wlen++ &&[](#l2.26)
(wbuf = PyMem_RawMalloc(wlen * sizeof(wchar_t)))) {[](#l2.27)
wlen = MultiByteToWideChar(CP_UTF8, 0, prompt, -1,[](#l2.28)
wbuf, wlen);[](#l2.29)
if (wlen) {[](#l2.30)
DWORD n;[](#l2.31)
fflush(stderr);[](#l2.32)
WriteConsoleW(hStdErr, wbuf, wlen, &n, NULL);[](#l2.33)
}[](#l2.34)
PyMem_RawFree(wbuf);[](#l2.35)
}[](#l2.36)
} else {[](#l2.37)
fprintf(stderr, "%s", prompt);[](#l2.38)
fflush(stderr);[](#l2.39)
}[](#l2.40)
}[](#l2.41) clearerr(sys_stdin);[](#l2.42) return _PyOS_WindowsConsoleReadline(hStdIn);[](#l2.43) }[](#l2.44)