8000 bpo-44859: Improve error handling in sqlite3 and change some errors by serhiy-storchaka · Pull Request #27654 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44859: Improve error handling in sqlite3 and change some errors #27654

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

Merged
merged 2 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply suggestions from code review
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
  • Loading branch information
serhiy-storchaka and Erlend Egeberg Aasland authored Aug 7, 2021
commit 664b14e6d738b32c2f64585576d3373d1d82e56e
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Improve error handling in :mod:`sqlite3` and change some errors to more
appropriate.
Improve error handling in :mod:`sqlite3` and raise more accurate exceptions.

* :exc:`MemoryError` is now raised instead of :exc:`sqlite3.Warning` when memory is not enough for encoding a statement to UTF-8 in ``Connection.__call__()`` and ``Cursor.execute()``.
* :exc:`UnicodEncodeError` is now raised instead of :exc:`sqlite3.Warning` when the statement contains surrogate characters in ``Connection.__call__()`` and ``Cursor.execute()``.
* :exc:`TypeError` is now raised instead of :exc:`ValueError` for non-string script argument in ``Cursor.executescript()``.
* :exc:`ValueError` is now raised for script containing the null character instead of truncating it in ``Cursor.executescript()``.
* Correctly handle exceptions raised when getting boolean value of the result of the progress handler.
* Add may tests covering different exceptional cases.
* Add many tests covering different corner cases.
3 changes: 2 additions & 1 deletion Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,8 @@ static int _progress_handler(void* user_arg)
if (!ret) {
/* abort query if error occurred */
rc = -1;
} else {
}
else {
rc = PyObject_IsTrue(ret);
Py_DECREF(ret);
}
Expand Down
0