BUG?: Saving empty array in shelve

Peter Otten __peter__ at web.de
Mon Apr 2 08:03:02 EDT 2007


iwl wrote:

> I've tryed to save some data containing empty arrays (array('f')) in a
> shelve.
> It looks like the shelve has some problems with empty arrays, get
> allways:
> TypeError: ("'NoneType' object is not iterable", <type 'array.array'>,
> ('f', None))-
> Messages when dealing with the readed back shelve.
> Seems like I have to avoid empty arrays in a shelve.

That seems to be a bug in the underlying pickling mechanism:

>>> from array import array
>>> from cPickle import loads, dumps
>>> loads(dumps(array("f", [1])))
array('f', [1.0])
>>> loads(dumps(array("f")))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ("'NoneType' object is not iterable", <type 'array.array'>, ('f',
None))

Please submit a bug report.

Peter



More information about the Python-list mailing list