8000 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
[go: up one dir, main page]

Skip to content

gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs #108281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Next Next commit
gh-108278: Clean up some sqlite3 connection APIs
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)

Deprecate passing the callback as a keyword argument, for the following
sqlite3.Connection APIs:

- set_authorizer(callback)
- set_progress_handler(callback, n)
- set_trace_callback(callback)

The affected parameters will become positional-only in Python 3.15.
  • Loading branch information
erlend-aasland committed Aug 22, 2023
commit 4f89b4cd228ceef06dc2caacafc6c465e2bb9e6f
19 changes: 18 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,24 @@ 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.

Deprecate passing the callback as a keyword argument, for the following
:class:`sqlite3.Connection` APIs:

- :meth:`~sqlite3.Connection.set_authorizer`
- :meth:`~sqlite3.Connection.set_progress_handler`
- :meth:`~sqlite3.Connection.set_trace_callback`

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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`

Deprecate passing the callback as a keyword argument, for the following
:class:`sqlite3.Connection` APIs:

- :meth:`~sqlite3.Connection.set_authorizer` -
:meth:`~sqlite3.Connection.set_progress_handler` -
:meth:`~sqlite3.Connection.set_trace_callback`

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

Patch by Erlend E. Aasland.
143 changes: 137 additions & 6 deletions Modules/_sqlite/clinic/connection.c.h

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

15 changes: 10 additions & 5 deletions Modules/_sqlite/connection.c
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 Expand Up @@ -1499,6 +1501,7 @@ _sqlite3.Connection.set_authorizer as pysqlite_connection_set_authorizer
cls: defining_class
/
authorizer_callback as callable: object
/ [from 3.15]

Sets authorizer callback.
[clinic start generated code]*/
Expand All @@ -1507,7 +1510,7 @@ static PyObject *
pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable)
/*[clinic end generated code: output=75fa60114fc971c3 input=605d32ba92dd3eca]*/
/*[clinic end generated code: output=75fa60114fc971c3 input=d4bf5013974daf98]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
Expand Down Expand Up @@ -1541,6 +1544,7 @@ _sqlite3.Connection.set_progress_handler as pysqlite_connection_set_progress_han
cls: defining_class
/
progress_handler as callable: object
/ [from 3.15]
n: int

Sets progress handler callback.
Expand All @@ -1550,7 +1554,7 @@ static PyObject *
pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable, int n)
/*[clinic end generated code: output=0739957fd8034a50 input=f7c1837984bd86db]*/
/*[clinic end generated code: output=0739957fd8034a50 input=9c8776d84cefd42b]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
Expand Down Expand Up @@ -1578,6 +1582,7 @@ _sqlite3.Connection.set_trace_callback as pysqlite_connection_set_trace_callback
cls: defining_class
/
trace_callback as callable: object
/ [from 3.15]

Sets a trace callback called for each SQL statement (passed as unicode).
[clinic start generated code]*/
Expand All @@ -1586,7 +1591,7 @@ static PyObject *
pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable)
/*[clinic end generated code: output=d91048c03bfcee05 input=351a94210c5f81bb]*/
/*[clinic end generated code: output=d91048c03bfcee05 input=69944bec571b97d2]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
Expand Down
0