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.

Author martin.panter
Recipients christian.heimes, martin.panter, neologix, pitrou
Date 2017-01-22.13:47:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485092861.97.0.0667849204017.issue29343@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-01-22 13:47:42martin.pantersetrecipients: + martin.panter, pitrou, christian.heimes, neologix
2017-01-22 13:47:41martin.pantersetmessageid: <1485092861.97.0.0667849204017.issue29343@psf.upfronthosting.co.za>
2017-01-22 13:47:41martin.panterlinkissue29343 messages
2017-01-22 13:47:41martin.pantercreate