From 33a40003745302eff5e6031d24d26642763fb6d8 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 21 Mar 2014 11:24:40 -0400 Subject: Issue #20627: xmlrpc.client.ServerProxy is now a context manager. Patch by Claudiu Popa. --- Lib/xmlrpc/client.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Lib/xmlrpc/client.py') diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index c2ae7070f9a..567554da37e 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 -- cgit v1.2.3