Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
In Python 3.13, sqlite is the new default for creating databases (https://www.python.org/downloads/release/python-3130/). However, it seems that it is not possible to get the keys of the database if the database file is in a read-only folder.
The setup:
mkdir PythonTestcd PythonTestpython -c "import shelve; shelve.open('db.db', 'c')"cd ..chmod 555 PythonTestThen running
importshelvewithshelve.open('PythonTest/db.db','r')asdb:print(list(db.keys()))
will fail with
Traceback (most recent call last): File "/usr/lib/python3.13/dbm/sqlite3.py", line 79, in _execute return closing(self._cx.execute(*args, **kwargs)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^sqlite3.OperationalError: attempt to write a readonly databaseDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "/read.py", line 5, in <module> print(list(db.keys())) ~~~~^^^^^^^^^^^ File "<frozen _collections_abc>", line 854, in __len__ File "/usr/lib/python3.13/shelve.py", line 99, in __len__ return len(self.dict) File "/usr/lib/python3.13/dbm/sqlite3.py", line 84, in __len__ with self._execute(GET_SIZE) as cu: ~~~~~~~~~~~~~^^^^^^^^^^ File "/usr/lib/python3.13/dbm/sqlite3.py", line 81, in _execute raise error(str(exc))dbm.sqlite3.error: attempt to write a readonly databasewhich I believe to be unexpected since the database was opened with ther flag, for read-only (seehttps://docs.python.org/3/library/dbm.html#dbm.open).
CPython versions tested on:
3.13.2 and 3.13.3
Operating systems tested on:
Linux (Ubuntu 24, Arch Linux)
Linked PRs
- gh-135386: Fix "unable to open database file" errors on readonly DB #135566
- [3.14] gh-135386: Fix "unable to open database file" errors on readonly DB (GH-135566) #138056
- [3.13] gh-135386: Fix "unable to open database file" errors on readonly DB (GH-135566) #138057
- gh-135386: Skip readonly tests for the root user #138058
- [3.13] gh-135386: Skip readonly tests for the root user (GH-138058) #138064
Metadata
Metadata
Assignees
Labels
Projects
Status
Done