diff options
author | Guido van Rossum <guido@python.org> | 1995-03-09 14:08:35 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-03-09 14:08:35 (GMT) |
commit | 7849da863191895030ea103875b313a4f3f3276d (patch) | |
tree | a58cc2ea14d473a84b0dc2f5a22d812cd9bb0291 /Lib | |
parent | a320fd308c9c8ac4775f83d2b8edb9af90192741 (diff) | |
download | cpython-7849da863191895030ea103875b313a4f3f3276d.zip cpython-7849da863191895030ea103875b313a4f3f3276d.tar.gz cpython-7849da863191895030ea103875b313a4f3f3276d.tar.bz2 |
added PicklingError exception
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pickle.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 7984b98..44447d4 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -126,11 +126,13 @@ I have no answers. Garbage Collection may also become a problem here.) """ __format_version__ = "1.0" # File format version -__version__ = "1.2" # Code version +__version__ = "1.4" # Code version from types import * import string +PicklingError = "pickle.PicklingError" + AtomicTypes = [NoneType, IntType, FloatType, StringType] def safe(object): @@ -191,7 +193,12 @@ class Pickler: self.write(GET + `d` + '\n') return t = type(object) - self.dispatch[t](self, object) + try: + f = self.dispatch[t] + except KeyError: + raise PicklingError, \ + "can't pickle %s objects" % `t.__name__` + f(self, object) def persistent_id(self, object): return None |