Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4116592

Browse files
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 keywordarguments, 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.
1 parentbc5356b commit4116592

File tree

6 files changed

+112
-6
lines changed

6 files changed

+112
-6
lines changed

‎Doc/library/sqlite3.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,11 @@ Connection objects
763763
...print(row)
764764
('acbd18db4cc2f85cedef654fccc4a4d8',)
765765

766+
..versionchanged::3.13
767+
768+
Passing *name*, *narg*, and *func* as keyword arguments is deprecated.
769+
These parameters will become positional-only in Python 3.15.
770+
766771

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

@@ -817,6 +822,11 @@ Connection objects
817822

818823
3
819824

825+
..versionchanged::3.13
826+
827+
Passing *name*, *n_arg*, and *aggregate_class* as keyword arguments is deprecated.
828+
These parameters will become positional-only in Python 3.15.
829+
820830

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

‎Doc/whatsnew/3.13.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,16 @@ Deprecated
252252
* Passing more than one positional argument to:func:`sqlite3.connect` and the
253253
:class:`sqlite3.Connection` constructor is deprecated. The remaining
254254
parameters will become keyword-only in Python 3.15.
255-
(Contributed by Erlend E. Aasland in:gh:`107948`.)
255+
256+
Deprecate passing name, number of arguments, and the callable as keyword
257+
arguments, for the following:class:`sqlite3.Connection` APIs:
258+
259+
*:meth:`~sqlite3.Connection.create_function`
260+
*:meth:`~sqlite3.Connection.create_aggregate`
261+
262+
The affected parameters will become positional-only in Python 3.15.
263+
264+
(Contributed by Erlend E. Aasland in:gh:`107948` and:gh:`108278`.)
256265

257266
Pending Removal in Python 3.14
258267
------------------------------

‎Lib/test/test_sqlite3/test_userfunctions.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,29 @@ def test_func_return_illegal_value(self):
421421
self.assertRaisesRegex(sqlite.OperationalError,msg,
422422
self.con.execute,"select badreturn()")
423423

424+
deftest_func_keyword_args(self):
425+
regex= (
426+
r"Passing keyword arguments 'name', 'narg' and 'func' to "
427+
r"_sqlite3.Connection.create_function\(\) is deprecated. "
428+
r"Parameters 'name', 'narg' and 'func' will become "
429+
r"positional-only in Python 3.15."
430+
)
431+
432+
defnoop():
433+
returnNone
434+
435+
withself.assertWarnsRegex(DeprecationWarning,regex)ascm:
436+
self.con.create_function("noop",0,func=noop)
437+
self.assertEqual(cm.filename,__file__)
438+
439+
withself.assertWarnsRegex(DeprecationWarning,regex)ascm:
440+
self.con.create_function("noop",narg=0,func=noop)
441+
self.assertEqual(cm.filename,__file__)
442+
443+
withself.assertWarnsRegex(DeprecationWarning,regex)ascm:
444+
self.con.create_function(name="noop",narg=0,func=noop)
445+
self.assertEqual(cm.filename,__file__)
446+
424447

425448
classWindowSumInt:
426449
def__init__(self):
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Deprecate passing name, number of arguments, and the callable as keyword
2+
arguments, for the following:class:`sqlite3.Connection` APIs:
3+
4+
*:meth:`~sqlite3.Connection.create_function`
5+
*:meth:`~sqlite3.Connection.create_aggregate`
6+
7+
The affected parameters will become positional-only in Python 3.15.
8+
9+
Patch by Erlend E. Aasland.

‎Modules/_sqlite/clinic/connection.c.h

Lines changed: 56 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Modules/_sqlite/connection.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ _sqlite3.Connection.create_function as pysqlite_connection_create_function
11391139
name: str
11401140
narg: int
11411141
func: object
1142+
/ [from 3.15]
11421143
*
11431144
deterministic: bool = False
11441145
@@ -1150,7 +1151,7 @@ pysqlite_connection_create_function_impl(pysqlite_Connection *self,
11501151
PyTypeObject*cls,constchar*name,
11511152
intnarg,PyObject*func,
11521153
intdeterministic)
1153-
/*[clinic end generated code: output=8a811529287ad240 input=b3e8e1d8ddaffbef]*/
1154+
/*[clinic end generated code: output=8a811529287ad240 input=c7c313b0ca8b519e]*/
11541155
{
11551156
intrc;
11561157
intflags=SQLITE_UTF8;
@@ -1341,6 +1342,7 @@ _sqlite3.Connection.create_aggregate as pysqlite_connection_create_aggregate
13411342
name: str
13421343
n_arg: int
13431344
aggregate_class: object
1345+
/ [from 3.15]
13441346
13451347
Creates a new aggregate.
13461348
[clinic start generated code]*/
@@ -1350,7 +1352,7 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
13501352
PyTypeObject*cls,
13511353
constchar*name,intn_arg,
13521354
PyObject*aggregate_class)
1353-
/*[clinic end generated code: output=1b02d0f0aec7ff96 input=68a2a26366d4c686]*/
1355+
/*[clinic end generated code: output=1b02d0f0aec7ff96 input=8087056db6eae1cf]*/
13541356
{
13551357
intrc;
13561358

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp