Skip to content

sqlite: Handle state invalidation when Connection.__init__ fails during re-initialization #6287

@ever0de

Description

@ever0de

Currently, sqlite3 does not correctly update the internal state of a Connection object if __init__ is called a second time and fails (e.g., due to an OperationalError).

Expected Behavior
If Connection.__init__ fails (even on an already open connection), the object should be considered uninitialized. Subsequent attempts to use methods like executemany should raise a sqlite3.ProgrammingError with the message "Base Connection.init not called", matching CPython's behavior.

Context
This behavior is required to pass test_connection_bad_reinit. We need to ensure the connection's initialized flag is reset or checked properly when re-initialization fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions