FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs by erlend-aasland · Pull Request #108281 · python/cpython · GitHub

Repository navigation

10 changes: 10 additions & 0 deletions Doc/library/sqlite3.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,11 @@ Connection objects
... print(row)
('acbd18db4cc2f85cedef654fccc4a4d8',)

.. versionchanged:: 3.13

Passing *name*, *narg*, and *func* as keyword arguments is deprecated.
These parameters will become positional-only in Python 3.15.


.. method:: create_aggregate(name, n_arg, aggregate_class)

Expand Down Expand Up @@ -817,6 +822,11 @@ Connection objects

3

.. versionchanged:: 3.13

Passing *name*, *n_arg*, and *aggregate_class* as keyword arguments is deprecated.
These parameters will become positional-only in Python 3.15.


.. method:: create_window_function(name, num_params, aggregate_class, /)

Expand Down
11 changes: 10 additions & 1 deletion Doc/whatsnew/3.13.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,16 @@ Deprecated
* Passing more than one positional argument to :func:`sqlite3.connect` and the
:class:`sqlite3.Connection` constructor is deprecated. The remaining
parameters will become keyword-only in Python 3.15.
(Contributed by Erlend E. Aasland in :gh:`107948`.)

Deprecate passing name, number of arguments, and the callable as keyword
arguments, for the following :class:`sqlite3.Connection` APIs:

* :meth:`~sqlite3.Connection.create_function`
* :meth:`~sqlite3.Connection.create_aggregate`

The affected parameters will become positional-only in Python 3.15.

(Contributed by Erlend E. Aasland in :gh:`107948` and :gh:`108278`.)

Pending Removal in Python 3.14
------------------------------
Expand Down
23 changes: 23 additions & 0 deletions Lib/test/test_sqlite3/test_userfunctions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Deprecate passing name, number of arguments, and the callable as keyword
arguments, for the following :class:`sqlite3.Connection` APIs:

* :meth:`~sqlite3.Connection.create_function`
* :meth:`~sqlite3.Connection.create_aggregate`

The affected parameters will become positional-only in Python 3.15.

Patch by Erlend E. Aasland.
59 changes: 56 additions & 3 deletions Modules/_sqlite/clinic/connection.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Modules/_sqlite/connection.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ _sqlite3.Connection.create_function as pysqlite_connection_create_function
name: str
narg: int
func: object
/ [from 3.15]
*
deterministic: bool = False

Expand All @@ -1150,7 +1151,7 @@ pysqlite_connection_create_function_impl(pysqlite_Connection *self,
PyTypeObject *cls, const char *name,
int narg, PyObject *func,
int deterministic)
/*[clinic end generated code: output=8a811529287ad240 input=b3e8e1d8ddaffbef]*/
/*[clinic end generated code: output=8a811529287ad240 input=c7c313b0ca8b519e]*/
{
int rc;
int flags = SQLITE_UTF8;
Expand Down Expand Up @@ -1341,6 +1342,7 @@ _sqlite3.Connection.create_aggregate as pysqlite_connection_create_aggregate
name: str
n_arg: int
aggregate_class: object
/ [from 3.15]

Creates a new aggregate.
[clinic start generated code]*/
Expand All @@ -1350,7 +1352,7 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
PyTypeObject *cls,
const char *name, int n_arg,
PyObject *aggregate_class)
/*[clinic end generated code: output=1b02d0f0aec7ff96 input=68a2a26366d4c686]*/
/*[clinic end generated code: output=1b02d0f0aec7ff96 input=8087056db6eae1cf]*/
{
int rc;

Expand Down

Back | FazBrowse Home | New Git URL