Message262456
| Author |
vstinner |
| Recipients |
serhiy.storchaka, vstinner |
| Date |
2016年03月25日.21:31:39 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<CAMpsgwb=RtZg7_T95+CrGeewdPKzBK6LS3s5wgG79oTAoj9qXg@mail.gmail.com> |
| In-reply-to |
<1458939275.12.0.657612765526.issue26642@psf.upfronthosting.co.za> |
| Content |
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 standard streams with "standard printers", and then close original streams? This allows to log warnings from closing streams.
Yeah, I tried this locally after sending my patch. I think that we
should keep a strong reference and only "decref" after the stream is
replaced.
> 3. "standard printers" are used at startup and at shutdown. Can we reuse some code? Or save and reuse "standard printers"?
I will check, it's maybe possible to share some code inside pylifecycle.c.
> 4. Daemons close standard streams and fileno(stdout) can return unrelevant value. Perhaps it is not good idea to recreate closed stdout.
Ah yes, while playing with my patch, I noticed that I replaced stdout
even if sys.stdout was NULL or None.
Closed stdout is a different thing. I guess that we can try to call
stdout.closed() and only replaced it with a standard printer it
closed() returns True (don't do it on error nor if closed() returns
false). |
|