Commit b25eb532 authored by Jason Madden's avatar Jason Madden

Fix unpickling POSError subclasses under PyPy. This fixes a bunch of...

Fix unpickling POSError subclasses under PyPy. This fixes a bunch of '<Unprintable POSKeyError>' tests in ZEO.
parent f2306514
......@@ -561,7 +561,7 @@ class DB(object):
# and we also want to pretend that doesn't exist.
# If we have no way to get a refcount, we return False to symbolize
# that. As opposed to None, this has the advantage of being usable
# as a number (0) in case clients depended on that
# as a number (0) in case clients depended on that.
detail.append({
'conn_no': cn,
'oid': oid,
......
......@@ -61,6 +61,16 @@ class POSError(Exception):
return (_recon, (self.__class__, state))
def __setstate__(self, state):
# PyPy doesn't store the 'args' attribute in an instance's
# __dict__; instead, it uses what amounts to a slot. Because
# we customize the pickled representation to just be a dictionary,
# the args would then get lost, leading to unprintable exceptions
# and worse. Manually assign to args from the state to be sure
# this doesn't happen.
super(POSError,self).__setstate__(state)
self.args = state['args']
class POSKeyError(POSError, KeyError):
"""Key not found in database."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment