diff options
author | Raymond Hettinger <python@rcn.com> | 2005-02-07 14:16:21 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-02-07 14:16:21 (GMT) |
commit | f715366f23f47832a4b9914c54d5a63b19f17eba (patch) | |
tree | ee5f60f4631f6fdad98711dc86ad128724effb11 /Lib/xmlrpclib.py | |
parent | a164574937d6ed32060ad34ea04913ca10741394 (diff) | |
download | cpython-f715366f23f47832a4b9914c54d5a63b19f17eba.zip cpython-f715366f23f47832a4b9914c54d5a63b19f17eba.tar.gz cpython-f715366f23f47832a4b9914c54d5a63b19f17eba.tar.bz2 |
Reduce the usage of the types module.
Diffstat (limited to 'Lib/xmlrpclib.py')
-rw-r--r-- | Lib/xmlrpclib.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index 7b68196..4d3305a 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -138,7 +138,7 @@ Exported functions: import re, string, time, operator -from types import * +from types import InstanceType # -------------------------------------------------------------------- # Internal stuff @@ -348,8 +348,8 @@ class DateTime: """ def __init__(self, value=0): - if not isinstance(value, StringType): - if not isinstance(value, (TupleType, time.struct_time)): + if not isinstance(value, str): + if not isinstance(value, (tuple, time.struct_time)): if value == 0: value = time.time() value = time.localtime(value) @@ -618,7 +618,7 @@ class Marshaller: if not self.allow_none: raise TypeError, "cannot marshal None unless allow_none is enabled" write("<value><nil/></value>") - dispatch[NoneType] = dump_nil + dispatch[type(None)] = dump_nil def dump_int(self, value, write): # in case ints are > 32 bits @@ -627,7 +627,7 @@ class Marshaller: write("<value><int>") write(str(value)) write("</int></value>\n") - dispatch[IntType] = dump_int + dispatch[int] = dump_int if _bool_is_builtin: def dump_bool(self, value, write): @@ -642,19 +642,19 @@ class Marshaller: write("<value><int>") write(str(int(value))) write("</int></value>\n") - dispatch[LongType] = dump_long + dispatch[long] = dump_long def dump_double(self, value, write): write("<value><double>") write(repr(value)) write("</double></value>\n") - dispatch[FloatType] = dump_double + dispatch[float] = dump_double def dump_string(self, value, write, escape=escape): write("<value><string>") write(escape(value)) write("</string></value>\n") - dispatch[StringType] = dump_string + dispatch[str] = dump_string if unicode: def dump_unicode(self, value, write, escape=escape): @@ -662,7 +662,7 @@ class Marshaller: write("<value><string>") write(escape(value)) write("</string></value>\n") - dispatch[UnicodeType] = dump_unicode + dispatch[unicode] = dump_unicode def dump_array(self, value, write): i = id(value) @@ -675,8 +675,8 @@ class Marshaller: dump(v, write) write("</data></array></value>\n") del self.memo[i] - dispatch[TupleType] = dump_array - dispatch[ListType] = dump_array + dispatch[tuple] = dump_array + dispatch[list] = dump_array def dump_struct(self, value, write, escape=escape): i = id(value) @@ -687,8 +687,8 @@ class Marshaller: write("<value><struct>\n") for k, v in value.items(): write("<member>\n") - if type(k) is not StringType: - if unicode and type(k) is UnicodeType: + if type(k) is not str: + if unicode and type(k) is unicode: k = k.encode(self.encoding) else: raise TypeError, "dictionary key must be string" @@ -697,7 +697,7 @@ class Marshaller: write("</member>\n") write("</struct></value>\n") del self.memo[i] - dispatch[DictType] = dump_struct + dispatch[dict] = dump_struct def dump_instance(self, value, write): # check for special wrappers @@ -1010,12 +1010,12 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None, where necessary. """ - assert isinstance(params, TupleType) or isinstance(params, Fault),\ + assert isinstance(params, tuple) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 - elif methodresponse and isinstance(params, TupleType): + elif methodresponse and isinstance(params, tuple): assert len(params) == 1, "response tuple must be a singleton" if not encoding: @@ -1036,7 +1036,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None, # standard XML-RPC wrappings if methodname: # a method call - if not isinstance(methodname, StringType): + if not isinstance(methodname, str): methodname = methodname.encode(encoding) data = ( xmlheader, @@ -1168,7 +1168,7 @@ class Transport: def get_host_info(self, host): x509 = {} - if isinstance(host, TupleType): + if isinstance(host, tuple): host, x509 = host import urllib @@ -1218,7 +1218,7 @@ class Transport: host, extra_headers, x509 = self.get_host_info(host) connection.putheader("Host", host) if extra_headers: - if isinstance(extra_headers, DictType): + if isinstance(extra_headers, dict): extra_headers = extra_headers.items() for key, value in extra_headers: connection.putheader(key, value) |