summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-09-15 20:25:57 (GMT)
committerGuido van Rossum <guido@python.org>1998-09-15 20:25:57 (GMT)
commit743d17e3aa77b84a57531cd74e1daba87132f807 (patch)
tree92e69b315a0b005773cd9025fb09f104f16dc216 /Lib/pickle.py
parent0c92000b7a679f1c8add378bb36c6c08efe6f6eb (diff)
downloadcpython-743d17e3aa77b84a57531cd74e1daba87132f807.zip
cpython-743d17e3aa77b84a57531cd74e1daba87132f807.tar.gz
cpython-743d17e3aa77b84a57531cd74e1daba87132f807.tar.bz2
In load_inst(), when instantiating an instance the old way (i.e. when
there's an __getinitargs__() method), if a TypeError occurs, catch and reraise it but add info to the error about the class name being instantiated. This makes debugging a lot easier if __getinitargs__() returns something bogus (e.g. a string instead of a singleton tuple).
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 0fde828..a4e442a 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -23,11 +23,11 @@ Misc variables:
"""
-__version__ = "1.9" # Code version
+__version__ = "$Revision$" # Code version
from types import *
from copy_reg import dispatch_table, safe_constructors
-import string, marshal
+import string, marshal, sys
format_version = "1.2" # File format version we write
compatible_formats = ["1.0", "1.1"] # Old format versions we can read
@@ -465,7 +465,6 @@ def whichmodule(cls, clsname):
"""
if classmap.has_key(cls):
return classmap[cls]
- import sys
for name, module in sys.modules.items():
if name != '__main__' and \
@@ -620,7 +619,11 @@ class Unpickler:
# prohibited
pass
if not instantiated:
- value = apply(klass, args)
+ try:
+ value = apply(klass, args)
+ except TypeError, err:
+ raise TypeError, "in constructor for %s: %s" % (
+ klass.__name__, str(err)), sys.exc_info()[2]
self.append(value)
dispatch[INST] = load_inst