summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-06-07 23:15:56 (GMT)
committerGuido van Rossum <guido@python.org>2007-06-07 23:15:56 (GMT)
commit1325790b932c4bab4f8f94f5a36c09f4036ed9f8 (patch)
tree5f4c1d854783a4d082c5867094ec345f4772bf35 /Lib/pickle.py
parent7b955bd125951db694f19a1b8648b806b14bd61f (diff)
downloadcpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.zip
cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.tar.gz
cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.tar.bz2
Merged revisions 55795-55816 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55797 | neal.norwitz | 2007-06-07 00:00:57 -0700 (Thu, 07 Jun 2007) | 3 lines Get rid of some remnants of classic classes. types.ClassType == type. Also get rid of almost all uses of the types module and use the builtin name. ........ r55798 | neal.norwitz | 2007-06-07 00:12:36 -0700 (Thu, 07 Jun 2007) | 1 line Remove a use of types, verify commit hook works ........ r55809 | guido.van.rossum | 2007-06-07 11:11:29 -0700 (Thu, 07 Jun 2007) | 2 lines Fix syntax error introduced by Neal in last checkin. ........
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index a028d9d..b950717 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -26,7 +26,7 @@ Misc variables:
__version__ = "$Revision$" # Code version
-from types import *
+from types import FunctionType, BuiltinFunctionType
from copy_reg import dispatch_table
from copy_reg import _extension_registry, _inverted_registry, _extension_cache
import marshal
@@ -283,7 +283,7 @@ class Pickler:
# Check for a class with a custom metaclass; treat as regular class
try:
- issc = issubclass(t, TypeType)
+ issc = issubclass(t, type)
except TypeError: # t is not a class (old Boost; see SF #502085)
issc = 0
if issc:
@@ -313,7 +313,7 @@ class Pickler:
return
# Assert that reduce() returned a tuple
- if type(rv) is not TupleType:
+ if not isinstance(rv, tuple):
raise PicklingError("%s must return string or tuple" % reduce)
# Assert that it returned an appropriately sized tuple
@@ -342,7 +342,7 @@ class Pickler:
# This API is called by some subclasses
# Assert that args is a tuple or None
- if not isinstance(args, TupleType):
+ if not isinstance(args, tuple):
raise PicklingError("args from reduce() should be a tuple")
# Assert that func is callable
@@ -420,7 +420,7 @@ class Pickler:
def save_none(self, obj):
self.write(NONE)
- dispatch[NoneType] = save_none
+ dispatch[type(None)] = save_none
def save_bool(self, obj):
if self.proto >= 2:
@@ -452,7 +452,7 @@ class Pickler:
# Text pickle, or int too big to fit in signed 4-byte format.
self.write(INT + bytes(repr(obj)) + b'\n')
# XXX save_int is merged into save_long
- # dispatch[IntType] = save_int
+ # dispatch[int] = save_int
def save_long(self, obj, pack=struct.pack):
if self.bin:
@@ -483,14 +483,14 @@ class Pickler:
self.write(LONG4 + pack("<i", n) + encoded)
return
self.write(LONG + bytes(repr(obj)) + b'\n')
- dispatch[LongType] = save_long
+ dispatch[int] = save_long
def save_float(self, obj, pack=struct.pack):
if self.bin:
self.write(BINFLOAT + pack('>d', obj))
else:
self.write(FLOAT + bytes(repr(obj)) + b'\n')
- dispatch[FloatType] = save_float
+ dispatch[float] = save_float
def save_string(self, obj, pack=struct.pack):
if self.bin:
@@ -568,7 +568,7 @@ class Pickler:
self.write(TUPLE)
self.memoize(obj)
- dispatch[TupleType] = save_tuple
+ dispatch[tuple] = save_tuple
# save_empty_tuple() isn't used by anything in Python 2.3. However, I
# found a Pickler subclass in Zope3 that calls it, so it's not harmless
@@ -587,7 +587,7 @@ class Pickler:
self.memoize(obj)
self._batch_appends(iter(obj))
- dispatch[ListType] = save_list
+ dispatch[list] = save_list
# Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets
# out of synch, though.
@@ -636,8 +636,8 @@ class Pickler:
self.memoize(obj)
self._batch_setitems(iter(obj.items()))
- dispatch[DictionaryType] = save_dict
- if not PyStringMap is None:
+ dispatch[dict] = save_dict
+ if PyStringMap is not None:
dispatch[PyStringMap] = save_dict
def _batch_setitems(self, items):
@@ -715,10 +715,9 @@ class Pickler:
write(GLOBAL + bytes(module) + b'\n' + bytes(name) + b'\n')
self.memoize(obj)
- dispatch[ClassType] = save_global
dispatch[FunctionType] = save_global
dispatch[BuiltinFunctionType] = save_global
- dispatch[TypeType] = save_global
+ dispatch[type] = save_global
# Pickling helpers
@@ -1007,7 +1006,7 @@ class Unpickler:
del self.stack[k:]
instantiated = 0
if (not args and
- type(klass) is ClassType and
+ isinstance(klass, type) and
not hasattr(klass, "__getinitargs__")):
value = _EmptyClass()
value.__class__ = klass