diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2022-03-17 06:58:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 22:58:25 -0700 |
commit | 4674fd4e938eb4a29ccd5b12c15455bd2a41c335 (patch) | |
tree | 9b6d452caca59b4fa2e3eee150de2d3e098d73fa /Lib/test/test_sqlite3/test_dbapi.py | |
parent | 96568e995d840c66edb25b6b9d85e4dcccf5a936 (diff) | |
download | cpython-git-4674fd4e938eb4a29ccd5b12c15455bd2a41c335.tar.gz |
bpo-44859: Raise more accurate exceptions in `sqlite3` (GH-27695)
* Improve exception compliance with PEP 249
* Raise InterfaceError instead of ProgrammingError for SQLITE_MISUSE.
If SQLITE_MISUSE is raised, it is a sqlite3 module bug. Users of the
sqlite3 module are not responsible for using the SQLite C API correctly.
* Don't overwrite BufferError with ValueError when conversion to BLOB fails.
* Raise ProgrammingError instead of Warning if user tries to execute() more
than one SQL statement.
* Raise ProgrammingError instead of ValueError if an SQL query contains null characters.
* Make sure `_pysqlite_set_result` raises an exception if it returns -1.
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r-- | Lib/test/test_sqlite3/test_dbapi.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 4eb4e180bf..177c2cd327 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -652,8 +652,9 @@ class CursorTests(unittest.TestCase): self.cu.execute("select asdf") def test_execute_too_much_sql(self): - with self.assertRaises(sqlite.Warning): - self.cu.execute("select 5+4; select 4+5") + self.assertRaisesRegex(sqlite.ProgrammingError, + "You can only execute one statement at a time", + self.cu.execute, "select 5+4; select 4+5") def test_execute_too_much_sql2(self): self.cu.execute("select 5+4; -- foo bar") |