From: Brett Cannon Date: Mon, 4 Aug 2008 00:50:11 +0000 (+0000) Subject: Remove assignment to True/False and use of dict.has_key() to silence warnings X-Git-Tag: v2.6b3~150 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=814820bb28f04e7bf9467cecca8b0f89d8e509a2;p=thirdparty%2FPython%2Fcpython.git Remove assignment to True/False and use of dict.has_key() to silence warnings while running under -3. --- diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index f600de7f245e..a916fa11480d 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -282,10 +282,13 @@ class Fault(Error): # @param value A boolean value. Any true value is interpreted as True, # all other values are interpreted as False. +from sys import modules +mod_dict = modules[__name__].__dict__ if _bool_is_builtin: boolean = Boolean = bool # to avoid breaking code which references xmlrpclib.{True,False} - True, False = True, False + mod_dict['True'] = True + mod_dict['False'] = False else: class Boolean: """Boolean-value wrapper. @@ -316,7 +319,8 @@ else: def __nonzero__(self): return self.value - True, False = Boolean(1), Boolean(0) + mod_dict['True'] = Boolean(1) + mod_dict['False'] = Boolean(0) ## # Map true or false value to XML-RPC boolean values. @@ -333,6 +337,8 @@ else: """Convert any Python value to XML-RPC 'boolean'.""" return _truefalse[operator.truth(value)] +del modules, mod_dict + ## # Wrapper for XML-RPC DateTime values. This converts a time value to # the format used by XML-RPC. @@ -744,7 +750,7 @@ class Marshaller: def dump_array(self, value, write): i = id(value) - if self.memo.has_key(i): + if i in self.memo: raise TypeError, "cannot marshal recursive sequences" self.memo[i] = None dump = self.__dump @@ -758,7 +764,7 @@ class Marshaller: def dump_struct(self, value, write, escape=escape): i = id(value) - if self.memo.has_key(i): + if i in self.memo: raise TypeError, "cannot marshal recursive dictionaries" self.memo[i] = None dump = self.__dump