diff options
author | Brett Cannon <brett@python.org> | 2014-03-21 15:24:40 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2014-03-21 15:24:40 (GMT) |
commit | 33a40003745302eff5e6031d24d26642763fb6d8 (patch) | |
tree | 75787adf85b136178f9053a54a2ed46f3f98c247 /Lib/xmlrpc | |
parent | 051f37d2e739981eac45051f6f2b873d2ef4699f (diff) | |
download | cpython-33a40003745302eff5e6031d24d26642763fb6d8.zip cpython-33a40003745302eff5e6031d24d26642763fb6d8.tar.gz cpython-33a40003745302eff5e6031d24d26642763fb6d8.tar.bz2 |
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.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index c2ae707..567554d 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 |