Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe59dc1

Browse files
committed
Revert previous checkin.
1 parent f715366 commit fe59dc1

2 files changed

Lines changed: 34 additions & 34 deletions

File tree

Lib/pickle.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def save(self, obj):
288288

289289
# Check for a class with a custom metaclass; treat as regular class
290290
try:
291-
issc = issubclass(t, type)
291+
issc = issubclass(t, TypeType)
292292
except TypeError: # t is not a class (old Boost; see SF #502085)
293293
issc = 0
294294
if issc:
@@ -313,12 +313,12 @@ def save(self, obj):
313313
(t.__name__, obj))
314314

315315
# Check for string returned by reduce(), meaning "save as global"
316-
if type(rv) is str:
316+
if type(rv) is StringType:
317317
self.save_global(obj, rv)
318318
return
319319

320320
# Assert that reduce() returned a tuple
321-
if type(rv) is not tuple:
321+
if type(rv) is not TupleType:
322322
raise PicklingError("%s must return string or tuple" % reduce)
323323

324324
# Assert that it returned an appropriately sized tuple
@@ -347,7 +347,7 @@ def save_reduce(self, func, args, state=None,
347347
# This API is called by some subclasses
348348

349349
# Assert that args is a tuple or None
350-
if not isinstance(args, tuple):
350+
if not isinstance(args, TupleType):
351351
raise PicklingError("args from reduce() should be a tuple")
352352

353353
# Assert that func is callable
@@ -425,7 +425,7 @@ def save_reduce(self, func, args, state=None,
425425

426426
def save_none(self, obj):
427427
self.write(NONE)
428-
dispatch[type(None)] = save_none
428+
dispatch[NoneType] = save_none
429429

430430
def save_bool(self, obj):
431431
if self.proto >= 2:
@@ -456,7 +456,7 @@ def save_int(self, obj, pack=struct.pack):
456456
return
457457
# Text pickle, or int too big to fit in signed 4-byte format.
458458
self.write(INT + repr(obj) + '\n')
459-
dispatch[int] = save_int
459+
dispatch[IntType] = save_int
460460

461461
def save_long(self, obj, pack=struct.pack):
462462
if self.proto >= 2:
@@ -468,14 +468,14 @@ def save_long(self, obj, pack=struct.pack):
468468
self.write(LONG4 + pack("<i", n) + bytes)
469469
return
470470
self.write(LONG + repr(obj) + '\n')
471-
dispatch[long] = save_long
471+
dispatch[LongType] = save_long
472472

473473
def save_float(self, obj, pack=struct.pack):
474474
if self.bin:
475475
self.write(BINFLOAT + pack('>d', obj))
476476
else:
477477
self.write(FLOAT + repr(obj) + '\n')
478-
dispatch[float] = save_float
478+
dispatch[FloatType] = save_float
479479

480480
def save_string(self, obj, pack=struct.pack):
481481
if self.bin:
@@ -487,7 +487,7 @@ def save_string(self, obj, pack=struct.pack):
487487
else:
488488
self.write(STRING + repr(obj) + '\n')
489489
self.memoize(obj)
490-
dispatch[str] = save_string
490+
dispatch[StringType] = save_string
491491

492492
def save_unicode(self, obj, pack=struct.pack):
493493
if self.bin:
@@ -501,7 +501,7 @@ def save_unicode(self, obj, pack=struct.pack):
501501
self.memoize(obj)
502502
dispatch[UnicodeType] = save_unicode
503503

504-
if str == UnicodeType:
504+
if StringType == UnicodeType:
505505
# This is true for Jython
506506
def save_string(self, obj, pack=struct.pack):
507507
unicode = obj.isunicode()
@@ -527,7 +527,7 @@ def save_string(self, obj, pack=struct.pack):
527527
else:
528528
self.write(STRING + repr(obj) + '\n')
529529
self.memoize(obj)
530-
dispatch[str] = save_string
530+
dispatch[StringType] = save_string
531531

532532
def save_tuple(self, obj):
533533
write = self.write
@@ -580,7 +580,7 @@ def save_tuple(self, obj):
580580
self.write(TUPLE)
581581
self.memoize(obj)
582582

583-
dispatch[tuple] = save_tuple
583+
dispatch[TupleType] = save_tuple
584584

585585
# save_empty_tuple() isn't used by anything in Python 2.3. However, I
586586
# found a Pickler subclass in Zope3 that calls it, so it's not harmless
@@ -599,7 +599,7 @@ def save_list(self, obj):
599599
self.memoize(obj)
600600
self._batch_appends(iter(obj))
601601

602-
dispatch[list] = save_list
602+
dispatch[ListType] = save_list
603603

604604
# Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets
605605
# out of synch, though.
@@ -648,7 +648,7 @@ def save_dict(self, obj):
648648
self.memoize(obj)
649649
self._batch_setitems(obj.iteritems())
650650

651-
dispatch[dict] = save_dict
651+
dispatch[DictionaryType] = save_dict
652652
if not PyStringMap is None:
653653
dispatch[PyStringMap] = save_dict
654654

@@ -770,7 +770,7 @@ def save_global(self, obj, name=None, pack=struct.pack):
770770
dispatch[ClassType] = save_global
771771
dispatch[FunctionType] = save_global
772772
dispatch[BuiltinFunctionType] = save_global
773-
dispatch[type] = save_global
773+
dispatch[TypeType] = save_global
774774

775775
# Pickling helpers
776776

Lib/xmlrpclib.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138

139139
import re, string, time, operator
140140

141-
from types import InstanceType
141+
from types import *
142142

143143
# --------------------------------------------------------------------
144144
# Internal stuff
@@ -348,8 +348,8 @@ class DateTime:
348348
"""
349349

350350
def __init__(self, value=0):
351-
if not isinstance(value, str):
352-
if not isinstance(value, (tuple, time.struct_time)):
351+
if not isinstance(value, StringType):
352+
if not isinstance(value, (TupleType, time.struct_time)):
353353
if value == 0:
354354
value = time.time()
355355
value = time.localtime(value)
@@ -618,7 +618,7 @@ def dump_nil (self, value, write):
618618
if not self.allow_none:
619619
raise TypeError, "cannot marshal None unless allow_none is enabled"
620620
write("<value><nil/></value>")
621-
dispatch[type(None)] = dump_nil
621+
dispatch[NoneType] = dump_nil
622622

623623
def dump_int(self, value, write):
624624
# in case ints are > 32 bits
@@ -627,7 +627,7 @@ def dump_int(self, value, write):
627627
write("<value><int>")
628628
write(str(value))
629629
write("</int></value>\n")
630-
dispatch[int] = dump_int
630+
dispatch[IntType] = dump_int
631631

632632
if _bool_is_builtin:
633633
def dump_bool(self, value, write):
@@ -642,27 +642,27 @@ def dump_long(self, value, write):
642642
write("<value><int>")
643643
write(str(int(value)))
644644
write("</int></value>\n")
645-
dispatch[long] = dump_long
645+
dispatch[LongType] = dump_long
646646

647647
def dump_double(self, value, write):
648648
write("<value><double>")
649649
write(repr(value))
650650
write("</double></value>\n")
651-
dispatch[float] = dump_double
651+
dispatch[FloatType] = dump_double
652652

653653
def dump_string(self, value, write, escape=escape):
654654
write("<value><string>")
655655
write(escape(value))
656656
write("</string></value>\n")
657-
dispatch[str] = dump_string
657+
dispatch[StringType] = dump_string
658658

659659
if unicode:
660660
def dump_unicode(self, value, write, escape=escape):
661661
value = value.encode(self.encoding)
662662
write("<value><string>")
663663
write(escape(value))
664664
write("</string></value>\n")
665-
dispatch[unicode] = dump_unicode
665+
dispatch[UnicodeType] = dump_unicode
666666

667667
def dump_array(self, value, write):
668668
i = id(value)
@@ -675,8 +675,8 @@ def dump_array(self, value, write):
675675
dump(v, write)
676676
write("</data></array></value>\n")
677677
del self.memo[i]
678-
dispatch[tuple] = dump_array
679-
dispatch[list] = dump_array
678+
dispatch[TupleType] = dump_array
679+
dispatch[ListType] = dump_array
680680

681681
def dump_struct(self, value, write, escape=escape):
682682
i = id(value)
@@ -687,8 +687,8 @@ def dump_struct(self, value, write, escape=escape):
687687
write("<value><struct>\n")
688688
for k, v in value.items():
689689
write("<member>\n")
690-
if type(k) is not str:
691-
if unicode and type(k) is unicode:
690+
if type(k) is not StringType:
691+
if unicode and type(k) is UnicodeType:
692692
k = k.encode(self.encoding)
693693
else:
694694
raise TypeError, "dictionary key must be string"
@@ -697,7 +697,7 @@ def dump_struct(self, value, write, escape=escape):
697697
write("</member>\n")
698698
write("</struct></value>\n")
699699
del self.memo[i]
700-
dispatch[dict] = dump_struct
700+
dispatch[DictType] = dump_struct
701701

702702
def dump_instance(self, value, write):
703703
# check for special wrappers
@@ -1010,12 +1010,12 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
10101010
where necessary.
10111011
"""
10121012

1013-
assert isinstance(params, tuple) or isinstance(params, Fault),\
1013+
assert isinstance(params, TupleType) or isinstance(params, Fault),\
10141014
"argument must be tuple or Fault instance"
10151015

10161016
if isinstance(params, Fault):
10171017
methodresponse = 1
1018-
elif methodresponse and isinstance(params, tuple):
1018+
elif methodresponse and isinstance(params, TupleType):
10191019
assert len(params) == 1, "response tuple must be a singleton"
10201020

10211021
if not encoding:
@@ -1036,7 +1036,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
10361036
# standard XML-RPC wrappings
10371037
if methodname:
10381038
# a method call
1039-
if not isinstance(methodname, str):
1039+
if not isinstance(methodname, StringType):
10401040
methodname = methodname.encode(encoding)
10411041
data = (
10421042
xmlheader,
@@ -1168,7 +1168,7 @@ def getparser(self):
11681168
def get_host_info(self, host):
11691169

11701170
x509 = {}
1171-
if isinstance(host, tuple):
1171+
if isinstance(host, TupleType):
11721172
host, x509 = host
11731173

11741174
import urllib
@@ -1218,7 +1218,7 @@ def send_host(self, connection, host):
12181218
host, extra_headers, x509 = self.get_host_info(host)
12191219
connection.putheader("Host", host)
12201220
if extra_headers:
1221-
if isinstance(extra_headers, dict):
1221+
if isinstance(extra_headers, DictType):
12221222
extra_headers = extra_headers.items()
12231223
for key, value in extra_headers:
12241224
connection.putheader(key, value)

0 commit comments

Comments
 (0)