[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2017-07-25 Thread STINNER Victor
STINNER Victor added the comment: I'm not sure that it's correct to replace sys.stdout with a simple object which can use a different encoding. I prefer to just close this old issue (idea). -- resolution: -> out of date stage: -> resolved status: open -> closed

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-04-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I meant that C files stderr and stdout can be closed. Or it's file descriptors can be closed. I think in these cases fileno() or PyFile_NewStdPrinter() will fail. I'm trying to consider all possible cases. Standard streams can be: * Left original. * Set to

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-04-12 Thread STINNER Victor
STINNER Victor added the comment: @Serhiy: Would you mind reviewing replace_stdio-2.patch? -- ___ Python tracker ___

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-04-01 Thread STINNER Victor
STINNER Victor added the comment: +if (!closed) { +PyObject *res = PyObject_CallMethod(file, "close", ""); +PyErr_Clear(); +Py_XDECREF(res); +} +if (!dunder_closed) { +PyObject *res = PyObject_CallMethod(dunder_file, "close", ""); +

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-04-01 Thread STINNER Victor
STINNER Victor added the comment: Patch version 2: * check if the stream was already "closed" (see below and comment in the patch) * first replace stream and then close it and DECREF the object * don't close stdin anymore > 1. Is there a reason only name is closed, not dunder_name? (Josh's

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-03-25 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka added the comment: > 1. Is there a reason only name is closed, not dunder_name? (Josh's question, > but I'm interesting too). By default, sys.__stdout__ is sys.stdout. Is it ok to close the same file twice? > 2. Is it worth to first replace

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-03-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There are some questions. 1. Is there a reason only name is closed, not dunder_name? (Josh's question, but I'm interesting too). 2. Is it worth to first replace standard streams with "standard printers", and then close original streams? This allows to log

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-03-25 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___

[issue26642] Replace stdout and stderr with simple standard printers at Python exit

2016-03-25 Thread STINNER Victor
New submission from STINNER Victor: The Python shutdown process is complex and fragile. It was discussed in the issue #25654 to replace stdout and stderr with simple "standard printers" (implemented in C, don't depend on other Python objects or modules). Attached patch implements this idea.