Martin Panter added the comment:

I added this behaviour in 3.6 on purpose via Issue 26685.

The change also impacted Yury (see the original bug thread), but if I 
understood correctly, he eventually decided that it highlighted a problem in 
asyncio or his code (though the resulting asyncio pull request seems to have 
stalled). Before he came to that decision, I did suggest temporarily using 
DeprecationWarning instead of an exception: 
<https://bugs.python.org/issue26685#msg278949>.

IMO passing a freed file descriptor to close() is asking for trouble. The 
descriptor could be recycled, by another thread, or even internally by a 
function call in the same thread. Another problem is if you don’t end up 
calling socket.close(), the garbage collector may arbitrarily close an FD in 
use in the future.

Your example code was not realistic, but I would say the solution is either 
call socket.detach() rather than socket.fileno(), or don’t call os.close() and 
just call socket.close().

I think that Linux man page is talking more about asynchronous errors from a 
previous write call. Even if we tolerated other errors from close(), I would 
still like to treat EBADF as a real error.

----------
nosy: +martin.panter

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

Reply via email to