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
Currently, the
sqlite3module does not strictly enforce checks when methods are called on aBlobinstance if the underlying connection is closed. While theread()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 asqlite3.ProgrammingError.Context
This issue was identified during the review of PR #6286. The following methods in
crates/stdlib/src/sqlite.rsare missing theself.connection.is_closed()check before callingself.inner(vm):write()tell()seek()__enter__()__exit__()__getitem__(subscript)__setitem__(ass_subscript)Reference
ProgrammingErrorwhen operating on a blob with a… #6286ProgrammingErrorwhen operating on a blob with a… #6286 (comment)