summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-08-04 00:50:11 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-08-04 00:50:11 (GMT)
commit814820bb28f04e7bf9467cecca8b0f89d8e509a2 (patch)
tree4137ee79262dcff5b14bf2045c7d536c7b540996 /Lib
parent9bd059ff4eecfb10b56a04e611b4ddfd87cc1dab (diff)
downloadcpython-814820bb28f04e7bf9467cecca8b0f89d8e509a2.zip
cpython-814820bb28f04e7bf9467cecca8b0f89d8e509a2.tar.gz
cpython-814820bb28f04e7bf9467cecca8b0f89d8e509a2.tar.bz2
Remove assignment to True/False and use of dict.has_key() to silence warnings
while running under -3.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/xmlrpclib.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py
index f600de7..a916fa1 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