mirror of https://github.com/python/cpython
Issue #28333: Enables Unicode for ps1/ps2 and input() prompts. (Patch by Eryk Sun)
This commit is contained in:
commit
55d2ba74e2
|
@ -222,6 +222,8 @@ Library
|
||||||
Windows
|
Windows
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #28333: Enables Unicode for ps1/ps2 and input() prompts
|
||||||
|
|
||||||
- Issue #28251: Improvements to help manuals on Windows.
|
- Issue #28251: Improvements to help manuals on Windows.
|
||||||
|
|
||||||
- Issue #28110: launcher.msi has different product codes between 32-bit and
|
- Issue #28110: launcher.msi has different product codes between 32-bit and
|
||||||
|
|
|
@ -203,17 +203,37 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) {
|
if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) {
|
||||||
HANDLE hStdIn;
|
HANDLE hStdIn, hStdErr;
|
||||||
|
|
||||||
_Py_BEGIN_SUPPRESS_IPH
|
_Py_BEGIN_SUPPRESS_IPH
|
||||||
hStdIn = (HANDLE)_get_osfhandle(fileno(sys_stdin));
|
hStdIn = (HANDLE)_get_osfhandle(fileno(sys_stdin));
|
||||||
|
hStdErr = (HANDLE)_get_osfhandle(fileno(stderr));
|
||||||
_Py_END_SUPPRESS_IPH
|
_Py_END_SUPPRESS_IPH
|
||||||
|
|
||||||
if (_get_console_type(hStdIn) == 'r') {
|
if (_get_console_type(hStdIn) == 'r') {
|
||||||
fflush(sys_stdout);
|
fflush(sys_stdout);
|
||||||
if (prompt)
|
if (prompt) {
|
||||||
|
if (_get_console_type(hStdErr) == 'w') {
|
||||||
|
wchar_t *wbuf;
|
||||||
|
int wlen;
|
||||||
|
wlen = MultiByteToWideChar(CP_UTF8, 0, prompt, -1,
|
||||||
|
NULL, 0);
|
||||||
|
if (wlen++ &&
|
||||||
|
(wbuf = PyMem_RawMalloc(wlen * sizeof(wchar_t)))) {
|
||||||
|
wlen = MultiByteToWideChar(CP_UTF8, 0, prompt, -1,
|
||||||
|
wbuf, wlen);
|
||||||
|
if (wlen) {
|
||||||
|
DWORD n;
|
||||||
|
fflush(stderr);
|
||||||
|
WriteConsoleW(hStdErr, wbuf, wlen, &n, NULL);
|
||||||
|
}
|
||||||
|
PyMem_RawFree(wbuf);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
fprintf(stderr, "%s", prompt);
|
fprintf(stderr, "%s", prompt);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
clearerr(sys_stdin);
|
clearerr(sys_stdin);
|
||||||
return _PyOS_WindowsConsoleReadline(hStdIn);
|
return _PyOS_WindowsConsoleReadline(hStdIn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue