summaryrefslogtreecommitdiff
path: root/Lib/xmlrpc
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-03-21 11:24:40 -0400
committerBrett Cannon <brett@python.org>2014-03-21 11:24:40 -0400
commit33a40003745302eff5e6031d24d26642763fb6d8 (patch)
tree75787adf85b136178f9053a54a2ed46f3f98c247 /Lib/xmlrpc
parent051f37d2e739981eac45051f6f2b873d2ef4699f (diff)
downloadcpython-git-33a40003745302eff5e6031d24d26642763fb6d8.tar.gz
Issue #20627: xmlrpc.client.ServerProxy is now a context manager.
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/xmlrpc')
-rw-r--r--Lib/xmlrpc/client.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index c2ae7070f9..567554da37 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -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