Nick Coghlan <ncogh...@gmail.com> added the comment:

An interesting part of this story is *why* it doesn't crash in Py3k (despite 
explicitly closing the file descriptor in the same way as 2.x closes the C file 
pointer).

The reason is that PyFile_FromFd (the closest Py3k equivalent to 
PyFile_FromFile) will sometimes leave the file descriptor open, even if closefd 
is True. Specifically, this will happen if the raw file IO object fails to be 
created. Any subsequent failure while opening the file (e.g. while creating the 
line buffering or text wrapper) will trigger the same double close bug as 
occurs in 2.x.

io_open needs to be fixed so this behaviour is consistent: if creation of the 
raw file IO object fails and closefd is True, io_open should close the file 
descriptor so that the behaviour on error is consistent.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7732>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to