New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sqlite3] Improve backup error handling #87431
Comments
There are some issues with the error handling in pysqlite_connection_backup_impl():
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? |
I'm not sure about 1) because if target == source it means a user error. OperationalError is usually used for non-user errors.
|
Yes, my bad. ProgrammingError would be better. I'll throw up a PR for 3., then. |
The unit test suite shows one case of improved "exception text". I'd say it's an improvement. $ ./python.exe # with python/cpython#68774 applied
>>> import sqlite3
>>> c1 = sqlite3.connect(":memory:")
>>> c2 = sqlite3.connect(":memory:")
>>> c1.backup(c2, name="non-existing")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: unknown database non-existing
$ python3.10 # latest alpha from python.org
>>> import sqlite3
>>> c1 = sqlite3.connect(":memory:")
>>> c2 = sqlite3.connect(":memory:")
>>> c1.backup(c2, name="non-existing")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: SQL logic error |
I'd even consider a cryptic error message a minor usability bug and backport it to at least 3.10. |
3.9, I presume? Yeah, I guess so. |
Regarding 1: After thinking about it, I see nothing wrong with raising ValueError error. No need to change current behaviour. |
Yes, I was going too fast :) |
Thank you. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: