Skip to content

Align sqlite3 transaction handling for autocommit=False with CPython #8258

Description

@teddygood

Feature

RustPython exposes the three Connection.autocommit modes, but autocommit=False does not follow CPython's transaction lifecycle. A connection does not enter a transaction immediately, and commit() and rollback() do not open a new transaction afterward. Closing a connection and running executescript() also do not consistently preserve the selected mode.

CPython keeps a transaction open for autocommit=False, reopens one after commit() or rollback(), rolls back a pending transaction on close, and preserves the behavior of the True, False, and legacy modes in context managers, DML execution, and executescript().

This leaves six tests in Lib/test/test_sqlite3/test_transactions.py marked as expected failures. Invalid autocommit value validation is outside this scope.

Python Documentation or reference to CPython source code

Metadata

Metadata

Assignees

Labels

C-compatA discrepancy between RustPython and CPythonz-ca-2026Tag to track Contribution Academy 2026

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions