aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2013-02-07 11:45:51 +0100
committerArmin Rigo <arigo@tunes.org>2013-02-07 11:45:51 +0100
commit7d0885e4e0665fca95d80bed4b38aba013b7be7d (patch)
treef33791bcc09ee14016abe5689fcc6923d03a697d /lib_pypy/cPickle.py
parentthis should always import lib_pypy's sqlite3, never the host's (diff)
downloadpypy-7d0885e4e0665fca95d80bed4b38aba013b7be7d.tar.gz
pypy-7d0885e4e0665fca95d80bed4b38aba013b7be7d.tar.bz2
pypy-7d0885e4e0665fca95d80bed4b38aba013b7be7d.zip
Try to hide another small difference between pickle and cPickle.
Diffstat (limited to 'lib_pypy/cPickle.py')
-rw-r--r--lib_pypy/cPickle.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib_pypy/cPickle.py b/lib_pypy/cPickle.py
index dc11873a8f..c99d6ad58d 100644
--- a/lib_pypy/cPickle.py
+++ b/lib_pypy/cPickle.py
@@ -1,5 +1,5 @@
#
-# One-liner implementation of cPickle
+# Reimplementation of cPickle, mostly as a copy of pickle.py
#
from pickle import Pickler, dump, dumps, PickleError, PicklingError, UnpicklingError, _EmptyClass
@@ -131,6 +131,13 @@ mloads = marshal.loads
# Unpickling machinery
+class _Stack(list):
+ def pop(self, index=-1):
+ try:
+ return list.pop(self, index)
+ except IndexError:
+ raise UnpicklingError("unpickling stack underflow")
+
class Unpickler(object):
def __init__(self, file):
@@ -155,7 +162,7 @@ class Unpickler(object):
Return the reconstituted object hierarchy specified in the file.
"""
self.mark = object() # any new unique object
- self.stack = []
+ self.stack = _Stack()
self.append = self.stack.append
try:
key = ord(self.read(1))