Skip to content

sqlite: Raise ProgrammingError when operating on a closed connection in Blob methods #6289

@ever0de

Description

@ever0de

Currently, the sqlite3 module does not strictly enforce checks when methods are called on a Blob instance if the underlying connection is closed. While the read() method includes this check, other methods do not, leading to potential inconsistencies with CPython behavior.

Expected Behavior
To match CPython's behavior, calling blob methods like write(), tell(), seek(), etc., on a closed database connection should raise a sqlite3.ProgrammingError.

Context
This issue was identified during the review of PR #6286. The following methods in crates/stdlib/src/sqlite.rs are missing the self.connection.is_closed() check before calling self.inner(vm):

  • write()
  • tell()
  • seek()
  • __enter__()
  • __exit__()
  • __getitem__ (subscript)
  • __setitem__ (ass_subscript)

Reference

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