New submission from Erlend Egeberg Aasland <[email protected]>:
There are some issues with the error handling in
pysqlite_connection_backup_impl():
1. ValueError is returned if the target connection equals source connection.
Should be OperationalError, IMHO.
2. The aforementioned check is already performed by sqlite3_backup_init(), so
we should just let SQLite take care of it and let _pysqlite_seterror() set the
error if sqlite3_backup_init() returns NULL. This will also take care of 1.
3. The following comment seems to be wrong; errors are set on the connection
object, not on the backup handle:
/* We cannot use _pysqlite_seterror() here because the backup APIs do
not set the error status on the connection object, but rather on
the backup handle. */
After sqlite3_backup_finish(), we can just check the return code, and call
_pysqlite_seterror() on the connection and return NULL. The mentioned comment
can be removed.
Resolving these issues will save 18 lines of code, and make the backup function
easier to maintain.
Berker?
----------
components: Library (Lib)
messages: 387297
nosy: berker.peksag, erlendaasland
priority: normal
severity: normal
status: open
title: Improve sqlite3 backup error handling
type: enhancement
versions: Python 3.10
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43265>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com