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

Dmitry Dvoinikov dmitry at targeted.org
Wed Sep 24 08:31:20 CEST 2008


> Dmitry, this change is already done in 4.7.3pre9:

Thank you Jesus for the work that you do with bsddb.

> you'd better provide suggestion here to improve the API, instead
> of coding workarounds in your applications.

I'm purposely using just a very simple subset of the API,
very generic, partially because I want to have an option
to switch to a different embedded database just in case.

Therefore to me there is no need in advanced API, just

1. Open environment and database (with BSD-specific tuning)
2. Begin transaction
3. Get or set or delete a single item at a time (shelf-like)
4. Commit or rollback
5. Close environment and database

And no, no workarounds here, thank you very much :)

The only thing which I lacked so far was better handling
of catastrophic database corruptions which happen to me
sometimes. Having an option to "hard reset" a database
without restarting a process would be nice.

I'd also vote for the Win32 installer, because building
4.6 manually was not as easy as I would like it to. :)

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

Jesus Cea wrote:
> Dmitry Dvoinikov wrote:
>> 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:
> 
> Dmitry, this change is already done in 4.7.3pre9:
> 
> """
>         data = apply(self.db.get, args, kw)
>         try:
>             return cPickle.loads(data)
>         except (EOFError, TypeError, cPickle.UnpicklingError):
>             return data  # we may be getting the default value, or None,
>                          # so it doesn't need unpickled.
> 
> """
> 
> pybsddb 4.7.3 will be published next week, just after Python 2.6 release.
> 
> pybsddb 4.7.3 will work in Python 3.0, natively. But the API is subject
> to change, specially the unicode<->byte management. The API will be
> improved in future releases. Since I'm publishing a new version per
> month, you'd better provide suggestion here to improve the API, instead
> of coding workarounds in your applications.
> 
_______________________________________________
pybsddb mailing list
pybsddb at argo.es
http://mailman.argo.es/listinfo/pybsddb
http://www.argo.es/~jcea/programacion/pybsddb.htm




More information about the pybsddb mailing list