mirror of
https://github.com/python/cpython.git
synced 2025-10-27 03:34:32 +00:00
gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs (#108281)
Deprecate passing name, number of arguments, and the callable as keyword arguments, for the following sqlite3.Connection APIs: - create_function(name, nargs, callable, ...) - create_aggregate(name, nargs, callable) The affected parameters will become positional-only in Python 3.15.
This commit is contained in:
parent
bc5356bb5d
commit
4116592b6f
6 changed files with 112 additions and 6 deletions
|
|
@ -421,6 +421,29 @@ def test_func_return_illegal_value(self):
|
|||
self.assertRaisesRegex(sqlite.OperationalError, msg,
|
||||
self.con.execute, "select badreturn()")
|
||||
|
||||
def test_func_keyword_args(self):
|
||||
regex = (
|
||||
r"Passing keyword arguments 'name', 'narg' and 'func' to "
|
||||
r"_sqlite3.Connection.create_function\(\) is deprecated. "
|
||||
r"Parameters 'name', 'narg' and 'func' will become "
|
||||
r"positional-only in Python 3.15."
|
||||
)
|
||||
|
||||
def noop():
|
||||
return None
|
||||
|
||||
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
|
||||
self.con.create_function("noop", 0, func=noop)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
|
||||
self.con.create_function("noop", narg=0, func=noop)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
|
||||
self.con.create_function(name="noop", narg=0, func=noop)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
|
||||
class WindowSumInt:
|
||||
def __init__(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue