[docs] [issue24911] Context manager of socket.socket is not documented

Martin Panter report at bugs.python.org
Wed Feb 17 19:37:23 EST 2016

Martin Panter added the comment:

Thanks for the reviews.

In this new patch, I modified two existing examples, but did not add any new example. Does that work for you Yury?

Also modified example code for the socketserver module.

Victor: IMO the “with conn” in the example is not overkill. It ensures the client connection socket is cleaned up, which is completely independent of the server listening socket s.

What exceptions can you get out of conn.close()? I can only think of unusual programming errors like EBADF. I would prefer to remove close() as being redundant with the context manager.

Added file: http://bugs.python.org/file41943/socket-context.v2.patch

Python tracker <report at bugs.python.org>

More information about the docs mailing list