Issue #20627: xmlrpc.client.ServerProxy is now a context manager.

Patch by Claudiu Popa.
This commit is contained in:
Brett Cannon 2014-03-21 11:24:40 -04:00
parent 051f37d2e7
commit 33a4000374
5 changed files with 42 additions and 10 deletions

View file

@ -1449,6 +1449,12 @@ class ServerProxy:
return self.__transport
raise AttributeError("Attribute %r not found" % (attr,))
def __enter__(self):
return self
def __exit__(self, *args):
self.__close()
# compatibility
Server = ServerProxy