shelve ( or bsddb ) problem
Alex A. Nikiforov
nikifor at sky.inp.nsk.su
Wed Jun 27 01:25:16 EDT 2001
Roman Suzi <rnd at onego.ru> wrote:
> On 24 Jun 2001, Alex A. Nikiforov wrote:
>>
>>That is priogram:
>>
>>$ cat b.py
>>import bsddb
>>import shelve
>>
>>s = shelve.BsdDbShelf(bsddb.hashopen('qqqqa','c'))
>>s['a'] = [3,2,1]
>>print s['a']
>>s['a'] = [1,2,3]
>>print s['a']
>>s['a'] = range(1000)
>>print s['a'][500]
>>s['a'] = [1,2,3]
>>print s['a']
>>
>>That is result:
>>
>>$ python b.py
>>[3, 2, 1]
>>[1, 2, 3]
>>500
>>Traceback (innermost last):
>> File "b.py", line 12, in ?
>> print s['a']
>> File "/usr/lib/python1.5/shelve.py", line 64, in __getitem__
>> f = StringIO(self.dict[key])
>>KeyError: a
>>$
>>
>>? ? ? ? ?
>>
>>python-1.5.2-30 from RedHat
>>
>>(python-1.5.2-27 has the same problem too)
> $ rpm -q python
> python-1.5.2-13
Yes, this version has not this problem.
> - No problem here:
> [3, 2, 1]
> [1, 2, 3]
> 500
> [1, 2, 3]
> Run:
> rpm -Vf /usr/lib/python1.5/shelve.py
> to check Python installation.
>>Alexei Nikiforov
>>
> Sincerely yours, Roman Suzi
> --
> _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
> _/ Sunday, June 24, 2001 _/ Powered by Linux RedHat 6.2 _/
> _/ "Ok, I pulled the pin. Now what? Where are you going?" _/
I have found, the problem is in bsddb hash dictionary in described versions.
some thing like following does not work:
b = bsddb.hashopen('qqq','c')
b['a']=`range(500)`
b['a']='[1,2,3]'
b['a'] -- error
Early and later version seems has not this bag.
Alexei
More information about the Python-list
mailing list