]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-44859: Improve error handling in sqlite3 and and raise more accurate exceptions...
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 8 Aug 2021 05:49:44 +0000 (08:49 +0300)
committerGitHub <noreply@github.com>
Sun, 8 Aug 2021 05:49:44 +0000 (08:49 +0300)
commit0eec6276fdcdde5221370d92b50ea95851760c72
tree35fa0e56f83f404eb2120ec1963c6b5e15813d34
parentebecffdb6d5fffa4249f9a813f1fc1915926feb5
bpo-44859: Improve error handling in sqlite3 and and raise more accurate exceptions. (GH-27654)

* MemoryError is now raised instead of sqlite3.Warning when
  memory is not enough for encoding a statement to UTF-8
  in Connection.__call__() and Cursor.execute().
* UnicodEncodeError is now raised instead of sqlite3.Warning when
  the statement contains surrogate characters
  in Connection.__call__() and Cursor.execute().
* TypeError is now raised instead of ValueError for non-string
  script argument in Cursor.executescript().
* 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 many tests covering different corner cases.

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Lib/sqlite3/test/dbapi.py
Lib/sqlite3/test/hooks.py
Lib/sqlite3/test/regression.py
Lib/sqlite3/test/types.py
Lib/sqlite3/test/userfunctions.py
Misc/NEWS.d/next/Library/2021-08-07-17-28-56.bpo-44859.CCopjk.rst [new file with mode: 0644]
Modules/_sqlite/clinic/cursor.c.h
Modules/_sqlite/connection.c
Modules/_sqlite/cursor.c
Modules/_sqlite/statement.c