[pybsddb] Change in pickle behavior since Py3rc1 breaks dbshelve.get

Dmitry Dvoinikov dmitry at targeted.org
Sun Sep 21 14:48:57 CEST 2008


Dear list,

It looks like pickle module behaves differently in Py3rc1 with
respect to deserializing None:

in Py2x:
import cPickle
cPickle.loads(None) => throws TypeError

in Py3rc1:
import pickle
pickle.loads(None) => throws EOFError

I have no idea whether this change is intentional, but it does
break dbshelve.get, because lines 233-237 no longer work:

try:
    return pickle.loads(data)
except (TypeError, pickle.UnpicklingError):
    return data  # we may be getting the default value, or None,
                 # so it doesn't need unpickled.

because the EOFError exception is not intercepted.

Adding EOFError:

except (TypeError, pickle.UnpicklingError, EOFError):

makes at least the tests in my application here to run.

Sincerely,
Dmitry Dvoinikov
http://www.targeted.org/



More information about the pybsddb mailing list