Yury Selivanov added the comment: Another example: some asyncio (run with uvloop) code: conn, _ = lsock.accept() f = loop.create_task( loop.connect_accepted_socket( proto_factory, conn)) # More code loop.run_forever() conn.close()
Suppose the above snippet of code is some real-world program. Now, in Python 3.5 everything works as expected. In Python 3.6, "conn.close()" will raise an exception. Why: uvloop passes the FD of "conn" to libuv, which does its thing and closes the connection when it should be closed. Now: > 1. Your code should call sock0.detach() rather than fileno(), so that sock0 > no longer “owns” the file descriptor, or I can't modify "connect_accepted_socket" to call "detach" on "conn", as it would make "conn" unusable right after the call. This option can't be implemented, as it would break the backwards compatibility. > 2. libuv should not close file descriptors that it doesn’t own. This is not just about uvloop/libuv. It's about any Python program out there that will break in 3.6. A lot of code extracts the FD out of socket objects and does something with it. We can't just make socket.close() to raise in 3.6 -- that's not how backwards compatibility promise works. Guido, what do you think about this issue? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26685> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com