Skip to content
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
Next Next commit
Raise ProgrammingError if user tries to execute() more than one state…
…ment
  • Loading branch information
Erlend E. Aasland committed Aug 9, 2021
commit e51d6c14f144aaf05f0d9a8dc743ea49411db430
5 changes: 3 additions & 2 deletions Lib/sqlite3/test/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ def test_execute_illegal_sql(self):
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")
Expand Down
2 changes: 1 addition & 1 deletion Modules/_sqlite/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
}

if (pysqlite_check_remaining_sql(tail)) {
PyErr_SetString(connection->Warning,
PyErr_SetString(connection->ProgrammingError,
"You can only execute one statement at a time.");
goto error;
}
Expand Down