This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients serhiy.storchaka, vstinner
Date 2016-04-01.21:08:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1459544882.22.0.237659182074.issue26642@psf.upfronthosting.co.za>
In-reply-to
Content
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 question, but I'm interesting too).

Fixed.

> 2. Is it worth to first replace standard streams with "standard printers", and then close original streams? This allows to log warnings from closing streams.

Fixed.

> 3. "standard printers" are used at startup and at shutdown. Can we reuse some code?

I looked at the code creating standard printer during Python startup: it's just a few lines and it doesn't handle the case when stdout/stderr is already open. I don't think that it's worth to reuse code.

Anyway, with my new patch, the code is much more complex to handle the case if stderr and/or __stderr__ is "closed" (is NULL, None, getting closed attribute raises an error, or closed attribute is false).

> 4. Daemons close standard streams and fileno(stdout) can return unrelevant value.

Fixed.
History
Date User Action Args
2016-04-01 21:08:02vstinnersetrecipients: + vstinner, serhiy.storchaka
2016-04-01 21:08:02vstinnersetmessageid: <1459544882.22.0.237659182074.issue26642@psf.upfronthosting.co.za>
2016-04-01 21:08:02vstinnerlinkissue26642 messages
2016-04-01 21:08:02vstinnercreate