Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to read sqlite3 database keys in read-only directory with Python 3.13 with shelve #135386

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtopic-sqlite3type-bugAn unexpected behavior, bug, or error
@jmcarcell

Description

@jmcarcell

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 PythonTest

Then 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 database

which 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtopic-sqlite3type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp