[Python-checkins] r65467 - python/trunk/Lib/xmlrpclib.py

brett.cannon python-checkins at python.org
Mon Aug 4 02:50:11 CEST 2008


Author: brett.cannon
Date: Mon Aug  4 02:50:11 2008
New Revision: 65467

Log:
Remove assignment to True/False and use of dict.has_key() to silence warnings
while running under -3.


Modified:
   python/trunk/Lib/xmlrpclib.py

Modified: python/trunk/Lib/xmlrpclib.py
==============================================================================
--- python/trunk/Lib/xmlrpclib.py	(original)
+++ python/trunk/Lib/xmlrpclib.py	Mon Aug  4 02:50:11 2008
@@ -282,10 +282,13 @@
 # @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 @@
         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 @@
         """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 @@
 
     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 @@
 
     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


More information about the Python-checkins mailing list