gh-129928: Raise more accurate exception for incorrect sqlite3 UDF creation (#129941)

Consistently raise ProgrammingError if the user tries to create an UDF
with an invalid number of parameters.
This commit is contained in:
Erlend E. Aasland 2025-02-11 08:26:01 +01:00 committed by GitHub
parent 0dbe543d70
commit 3a2e7aacf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 6 deletions

View file

@ -171,7 +171,7 @@ def tearDown(self):
self.con.close()
def test_func_error_on_create(self):
with self.assertRaises(sqlite.OperationalError):
with self.assertRaisesRegex(sqlite.ProgrammingError, "not -100"):
self.con.create_function("bla", -100, lambda x: 2*x)
def test_func_too_many_args(self):
@ -507,9 +507,8 @@ def test_win_sum_int(self):
self.assertEqual(self.cur.fetchall(), self.expected)
def test_win_error_on_create(self):
self.assertRaises(sqlite.ProgrammingError,
self.con.create_window_function,
"shouldfail", -100, WindowSumInt)
with self.assertRaisesRegex(sqlite.ProgrammingError, "not -100"):
self.con.create_window_function("shouldfail", -100, WindowSumInt)
@with_tracebacks(BadWindow)
def test_win_exception_in_method(self):
@ -638,7 +637,7 @@ def tearDown(self):
self.con.close()
def test_aggr_error_on_create(self):
with self.assertRaises(sqlite.OperationalError):
with self.assertRaisesRegex(sqlite.ProgrammingError, "not -100"):
self.con.create_function("bla", -100, AggrSum)
@with_tracebacks(AttributeError, msg_regex="AggrNoStep")