[issue41941] Py_Initialize affects the console

2020-10-05 Thread Eryk Sun
Eryk Sun added the comment: > config_init_stdio() is not called in an isolated configuration: config_init_stdio wasn't being called anyway since Py_Initialize uses _PyConfig_InitCompatConfig. The issue was primarily due to the LC_CTYPE locale being set to the default user locale, as I discus

[issue41941] Py_Initialize affects the console

2020-10-05 Thread twoone3
twoone3 <3197653...@qq.com> added the comment: That's it -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue41941] Py_Initialize affects the console

2020-10-05 Thread STINNER Victor
STINNER Victor added the comment: PyConfig_InitIsolatedConfig() reduces side effects on the process. For example, it doesn't set the LC_CTYPE locale and it doesn't change the standard streams (stdio). config_init_stdio() is not called in an isolated configuration: https://github.com/python/

[issue41941] Py_Initialize affects the console

2020-10-05 Thread twoone3
twoone3 <3197653...@qq.com> added the comment: I used the link you gave me https://docs.python.org/dev/c-api/init_config.html#c.PyConfig.PyConfig_InitIsolatedConfig Click to open and turn up to see the box, I follow that box The example inside is done, and the coding problem of the console i

[issue41941] Py_Initialize affects the console

2020-10-05 Thread Eryk Sun
Eryk Sun added the comment: Having looked at the screenshots, it seems that your issue is in part due to non-legacy mode not setting the standard I/O files to binary mode (_O_BINARY) from their default ANSI text mode (_O_TEXT). This is not a problem on its own. The real issue is that you're

[issue41941] Py_Initialize affects the console

2020-10-05 Thread STINNER Victor
STINNER Victor added the comment: > This problem has bothered me for a month, thank you for helping me solve this > problem, you can close it I close the issue, but I'm not sure how you fixed it. Don't hesitate commenting to explain how you solved it ;-) -- resolution: -> not a bug

[issue41941] Py_Initialize affects the console

2020-10-05 Thread twoone3
twoone3 <3197653...@qq.com> added the comment: This problem has bothered me for a month, thank you for helping me solve this problem, you can close it -- ___ Python tracker __

[issue41941] Py_Initialize affects the console

2020-10-05 Thread STINNER Victor
STINNER Victor added the comment: I suggest you to use https://docs.python.org/dev/c-api/init_config.html#c.PyConfig.PyConfig_InitIsolatedConfig API instead of the legacy Py_Initialize() API. -- ___ Python tracker

[issue41941] Py_Initialize affects the console

2020-10-05 Thread twoone3
twoone3 <3197653...@qq.com> added the comment: So how does this explain -- Added file: https://bugs.python.org/file49495/Screenshots.zip ___ Python tracker ___

[issue41941] Py_Initialize affects the console

2020-10-05 Thread Eryk Sun
Change by Eryk Sun : -- components: +IO, Unicode, Windows nosy: +ezio.melotti, paul.moore, steve.dower, tim.golden, vstinner, zach.ware ___ Python tracker ___ _

[issue41941] Py_Initialize affects the console

2020-10-05 Thread Eryk Sun
Eryk Sun added the comment: Python supports Unicode in a Windows console session by using the console API's wide-character functions (i.e. ReadConsoleW and WriteConsoleW) with UTF-16 encoded text. This is implemented in the io stack via io._WindowsConsoleIO, and for PyOS_Readline (e.g. built

[issue41941] Py_Initialize affects the console

2020-10-05 Thread twoone3
New submission from twoone3 <3197653...@qq.com>: When I set Py_LegacyWindowsStdioFlag to 0, after Py_Initialize, the console will forcibly change what encoding is displayed. At this time, my standard stream output is utf-8, py's print is utf-8, chcp 65001 is useless, and still garbled. When