This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author HubTou
Recipients HubTou
Date 2022-03-20.17:29:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647797363.41.0.855477940011.issue47072@roundup.psfhosted.org>
In-reply-to
Content
After adding a few records, the shelve module corrupts the database keys (the database is still readable if an element key is known, but no more iterable):

Traceback (most recent call last):
  File "./shelve-test.py", line 81, in <module>
    _verify_whois_cache()
  File "./shelve-test.py", line 61, in _verify_whois_cache
    for key in db.keys():
  File "/usr/local/lib/python3.8/_collections_abc.py", line 720, in __iter__
    yield from self._mapping
  File "/usr/local/lib/python3.8/shelve.py", line 95, in __iter__
    for k in self.dict.keys():
SystemError: Negative size passed to PyBytes_FromStringAndSize

I provide a short test program and data that systematically reproduces the bug. I added the a script showing execution messages, the resulting database in DB and text formats.

Tested with Python 3.8.12 on FreeBSD 13.0-RELEASE-p8.
I suppose Python is using my system package db5-5.3.28_8                   (Oracle Berkeley DB, revision 5.3).

See also similar issues:
https://bugs.python.org/issue33074
https://bugs.python.org/issue30388
History
Date User Action Args
2022-03-20 17:29:23HubTousetrecipients: + HubTou
2022-03-20 17:29:23HubTousetmessageid: <1647797363.41.0.855477940011.issue47072@roundup.psfhosted.org>
2022-03-20 17:29:23HubToulinkissue47072 messages
2022-03-20 17:29:23HubToucreate