diff options
Diffstat (limited to 'Lib/xmlrpc/client.py')
-rw-r--r-- | Lib/xmlrpc/client.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index e8c1944fdb..047929a861 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -208,8 +208,8 @@ class ProtocolError(Error): self.headers = headers def __repr__(self): return ( - "<ProtocolError for %s: %s %s>" % - (self.url, self.errcode, self.errmsg) + "<%s for %s: %s %s>" % + (self.__class__.__name__, self.url, self.errcode, self.errmsg) ) ## @@ -237,7 +237,8 @@ class Fault(Error): self.faultCode = faultCode self.faultString = faultString def __repr__(self): - return "<Fault %s: %r>" % (self.faultCode, self.faultString) + return "<%s %s: %r>" % (self.__class__.__name__, + self.faultCode, self.faultString) # -------------------------------------------------------------------- # Special values @@ -339,10 +340,6 @@ class DateTime: s, o = self.make_comparable(other) return s == o - def __ne__(self, other): - s, o = self.make_comparable(other) - return s != o - def timetuple(self): return time.strptime(self.value, "%Y%m%dT%H:%M:%S") @@ -355,7 +352,7 @@ class DateTime: return self.value def __repr__(self): - return "<DateTime %r at %x>" % (self.value, id(self)) + return "<%s %r at %#x>" % (self.__class__.__name__, self.value, id(self)) def decode(self, data): self.value = str(data).strip() @@ -406,11 +403,6 @@ class Binary: other = other.data return self.data == other - def __ne__(self, other): - if isinstance(other, Binary): - other = other.data - return self.data != other - def decode(self, data): self.data = base64.decodebytes(data) @@ -847,7 +839,7 @@ class MultiCall: self.__call_list = [] def __repr__(self): - return "<MultiCall at %x>" % id(self) + return "<%s at %#x>" % (self.__class__.__name__, id(self)) __str__ = __repr__ @@ -1444,8 +1436,8 @@ class ServerProxy: def __repr__(self): return ( - "<ServerProxy for %s%s>" % - (self.__host, self.__handler) + "<%s for %s%s>" % + (self.__class__.__name__, self.__host, self.__handler) ) __str__ = __repr__ @@ -1467,6 +1459,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 |