summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-07-17 23:01:39 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-07-17 23:01:39 (GMT)
commit82a6bf049e2ccceb99e9288440ffffad77bf9e90 (patch)
treee017932277b114c8f83fa95c1ae95d8092fda626 /Lib/pickle.py
parent6fd1df8c44dd986d1ba6458c9583dacda4255180 (diff)
downloadcpython-82a6bf049e2ccceb99e9288440ffffad77bf9e90.zip
cpython-82a6bf049e2ccceb99e9288440ffffad77bf9e90.tar.gz
cpython-82a6bf049e2ccceb99e9288440ffffad77bf9e90.tar.bz2
Merged revisions 82937 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82937 | alexander.belopolsky | 2010-07-17 18:50:45 -0400 (Sat, 17 Jul 2010) | 3 lines Issue #5180: Fixed a bug that prevented loading 2.x pickles in 3.x python when they contain instances of old-style classes. ........
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 7b48527..5275991 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -1034,19 +1034,15 @@ class _Unpickler:
def _instantiate(self, klass, k):
args = tuple(self.stack[k+1:])
del self.stack[k:]
- instantiated = False
- if (not args and
- isinstance(klass, type) and
- not hasattr(klass, "__getinitargs__")):
- value = _EmptyClass()
- value.__class__ = klass
- instantiated = True
- if not instantiated:
+ if (args or not isinstance(klass, type) or
+ hasattr(klass, "__getinitargs__")):
try:
value = klass(*args)
except TypeError as err:
raise TypeError("in constructor for %s: %s" %
(klass.__name__, str(err)), sys.exc_info()[2])
+ else:
+ value = klass.__new__(klass)
self.append(value)
def load_inst(self):
@@ -1239,11 +1235,6 @@ class _Unpickler:
raise _Stop(value)
dispatch[STOP[0]] = load_stop
-# Helper class for load_inst/load_obj
-
-class _EmptyClass:
- pass
-
# Encode/decode longs in linear time.
import binascii as _binascii