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.

classification
Title: closed stdout causes error on stderr when the interpreter unconditionally flushes on shutdown
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, Ronny.Pfannschmidt, georg.brandl, jleedev, martin.panter, mkc, pitrou, python-dev, terry.reedy
Priority: normal Keywords:

Created on 2011-11-21 15:18 by Ronny.Pfannschmidt, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg148055 - (view) Author: Ronny Pfannschmidt (Ronny.Pfannschmidt) Date: 2011-11-21 15:18
not sure if this is to be considered a bug,
but python3.2 tries to flush sys.stdout on shutdown, even if its closed

$ python3.2 -c 'import sys;sys.stdout.close()'
Exception ValueError: 'I/O operation on closed file.' in <_io.TextIOWrapper name='<stdout>' mode='w' encoding='ANSI_X3.4-1968'> ignored

its related to how Issue #5319 was fixed
msg148155 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-22 23:46
I think closing stdout is a legitimate desire so, yes, I would consider it a bug if we print an error in that case.
A patch could either first check the "closed" attribute, or silence the ValueError.
msg148198 - (view) Author: Ronny Pfannschmidt (Ronny.Pfannschmidt) Date: 2011-11-23 18:04
i think checking for closed is the correct solution
msg148422 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-26 21:11
New changeset 150e096095e5 by Antoine Pitrou in branch '3.2':
Issue #13444: When stdout has been closed explicitly, we should not attempt to flush it at shutdown and print an error.
http://hg.python.org/cpython/rev/150e096095e5

New changeset 37300a1df7d7 by Antoine Pitrou in branch 'default':
Issue #13444: When stdout has been closed explicitly, we should not attempt to flush it at shutdown and print an error.
http://hg.python.org/cpython/rev/37300a1df7d7
msg231062 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-11-12 05:23
Shouldn’t this issue be marked closed and fixed?
History
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57653
2014-11-12 05:49:16berker.peksagsetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2014-11-12 05:23:35martin.pantersetnosy: + martin.panter
messages: + msg231062
2014-11-11 16:13:28jleedevsetnosy: + jleedev
2011-11-27 00:29:50Arfreversetnosy: + Arfrever
2011-11-26 21:11:58python-devsetnosy: + python-dev
messages: + msg148422
2011-11-23 18:04:41Ronny.Pfannschmidtsetmessages: + msg148198
2011-11-22 23:46:55pitrousettype: behavior
stage: needs patch
messages: + msg148155
versions: + Python 3.3
2011-11-21 15:18:19Ronny.Pfannschmidtcreate