[Python-3000] close() on open(fd, closefd=False)

Christian Heimes lists at cheimes.de
Fri Oct 31 22:50:39 CET 2008


Amaury has found an issue with open and closefd, 
http://bugs.python.org/issue4233

The additional warnings aren't critical. But in retrospection I think 
that I made a small error during the design of the closefd feature.
With a file descriptor number as first argument and closefd set to 
false, the file descriptor isn't closed when the file object is 
deallocated. It's also impossible to close the fd with close(). Right 
now close() doesn't do anything and you can still write or read after 
close(). This behavior is surprising to the user. I like to change 
close() to set the internal fd attribute to -1 (meaning close) but keep 
the fd open.

Maybe the warning could be dropped all along, too.

Christian



More information about the Python-3000 mailing list