gh-133595: Clean up sqlite3.Connection APIs (GH-133605)

* All parameters of sqlite3.connect() except "database" are now keyword-only.
* The first three parameters of methods create_function() and
  create_aggregate() are now positional-only.
* The first parameter of methods set_authorizer(), set_progress_handler()
  and set_trace_callback() is now positional-only.
This commit is contained in:
Serhiy Storchaka 2025-05-08 15:42:00 +03:00 committed by GitHub
parent 2561e148ec
commit dcf93c4c93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 117 additions and 445 deletions

View file

@ -259,10 +259,10 @@ Reference
Module functions
^^^^^^^^^^^^^^^^
.. function:: connect(database, timeout=5.0, detect_types=0, \
.. function:: connect(database, *, timeout=5.0, detect_types=0, \
isolation_level="DEFERRED", check_same_thread=True, \
factory=sqlite3.Connection, cached_statements=128, \
uri=False, *, \
uri=False, \
autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL)
Open a connection to an SQLite database.
@ -355,11 +355,8 @@ Module functions
.. versionchanged:: 3.12
Added the *autocommit* parameter.
.. versionchanged:: 3.13
Positional use of the parameters *timeout*, *detect_types*,
*isolation_level*, *check_same_thread*, *factory*, *cached_statements*,
and *uri* is deprecated.
They will become keyword-only parameters in Python 3.15.
.. versionchanged:: 3.15
All parameters except *database* are now keyword-only.
.. function:: complete_statement(statement)
@ -693,7 +690,7 @@ Connection objects
:meth:`~Cursor.executescript` on it with the given *sql_script*.
Return the new cursor object.
.. method:: create_function(name, narg, func, *, deterministic=False)
.. method:: create_function(name, narg, func, /, *, deterministic=False)
Create or remove a user-defined SQL function.
@ -719,6 +716,9 @@ Connection objects
.. versionchanged:: 3.8
Added the *deterministic* parameter.
.. versionchanged:: 3.15
The first three parameters are now positional-only.
Example:
.. doctest::
@ -733,13 +733,8 @@ Connection objects
('acbd18db4cc2f85cedef654fccc4a4d8',)
>>> con.close()
.. 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)
.. method:: create_aggregate(name, n_arg, aggregate_class, /)
Create or remove a user-defined SQL aggregate function.
@ -763,6 +758,9 @@ Connection objects
Set to ``None`` to remove an existing SQL aggregate function.
:type aggregate_class: :term:`class` | None
.. versionchanged:: 3.15
All three parameters are now positional-only.
Example:
.. testcode::
@ -792,11 +790,6 @@ 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, /)
@ -937,7 +930,7 @@ Connection objects
Aborted queries will raise an :exc:`OperationalError`.
.. method:: set_authorizer(authorizer_callback)
.. method:: set_authorizer(authorizer_callback, /)
Register :term:`callable` *authorizer_callback* to be invoked
for each attempt to access a column of a table in the database.
@ -962,12 +955,11 @@ Connection objects
.. versionchanged:: 3.11
Added support for disabling the authorizer using ``None``.
.. versionchanged:: 3.13
Passing *authorizer_callback* as a keyword argument is deprecated.
The parameter will become positional-only in Python 3.15.
.. versionchanged:: 3.15
The only parameter is now positional-only.
.. method:: set_progress_handler(progress_handler, n)
.. method:: set_progress_handler(progress_handler, /, n)
Register :term:`callable` *progress_handler* to be invoked for every *n*
instructions of the SQLite virtual machine. This is useful if you want to
@ -981,12 +973,11 @@ Connection objects
currently executing query and cause it to raise a :exc:`DatabaseError`
exception.
.. versionchanged:: 3.13
Passing *progress_handler* as a keyword argument is deprecated.
The parameter will become positional-only in Python 3.15.
.. versionchanged:: 3.15
The first parameter is now positional-only.
.. method:: set_trace_callback(trace_callback)
.. method:: set_trace_callback(trace_callback, /)
Register :term:`callable` *trace_callback* to be invoked
for each SQL statement that is actually executed by the SQLite backend.
@ -1009,9 +1000,8 @@ Connection objects
.. versionadded:: 3.3
.. versionchanged:: 3.13
Passing *trace_callback* as a keyword argument is deprecated.
The parameter will become positional-only in Python 3.15.
.. versionchanged:: 3.15
The first parameter is now positional-only.
.. method:: enable_load_extension(enabled, /)

View file

@ -143,7 +143,16 @@ New features
Porting to Python 3.15
----------------------
* TODO
* :class:`sqlite3.Connection` APIs has been cleaned up.
* All parameters of :func:`sqlite3.connect` except *database* are now keyword-only.
* The first three parameters of methods :meth:`~sqlite3.Connection.create_function`
and :meth:`~sqlite3.Connection.create_aggregate` are now positional-only.
* The first parameter of methods :meth:`~sqlite3.Connection.set_authorizer`,
:meth:`~sqlite3.Connection.set_progress_handler` and
:meth:`~sqlite3.Connection.set_trace_callback` is now positional-only.
(Contributed by Serhiy Storchaka in :gh:`133595`.)
Deprecated C APIs
-----------------

View file

@ -792,7 +792,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(add_done_callback));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_child));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_parent));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aggregate_class));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(alias));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(align));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(all));
@ -809,7 +808,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ast));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(athrow));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(attribute));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(authorizer_callback));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autocommit));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(backtick));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(base));
@ -1108,7 +1106,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(msg));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mutex));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mycmp));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_arg));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_fields));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_sequence_fields));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_unnamed_fields));
@ -1116,7 +1113,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(name_from));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(namespace_separator));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(namespaces));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(narg));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ndigits));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(nested));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(new_file_name));
@ -1174,7 +1170,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(print_file_and_line));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(priority));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(progress));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(progress_handler));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(progress_routine));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(proto));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(protocol));
@ -1280,7 +1275,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(timetuple));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(timeunit));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(top));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(trace_callback));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(traceback));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(trailers));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(translate));

View file

@ -283,7 +283,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(add_done_callback)
STRUCT_FOR_ID(after_in_child)
STRUCT_FOR_ID(after_in_parent)
STRUCT_FOR_ID(aggregate_class)
STRUCT_FOR_ID(alias)
STRUCT_FOR_ID(align)
STRUCT_FOR_ID(all)
@ -300,7 +299,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(ast)
STRUCT_FOR_ID(athrow)
STRUCT_FOR_ID(attribute)
STRUCT_FOR_ID(authorizer_callback)
STRUCT_FOR_ID(autocommit)
STRUCT_FOR_ID(backtick)
STRUCT_FOR_ID(base)
@ -599,7 +597,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(msg)
STRUCT_FOR_ID(mutex)
STRUCT_FOR_ID(mycmp)
STRUCT_FOR_ID(n_arg)
STRUCT_FOR_ID(n_fields)
STRUCT_FOR_ID(n_sequence_fields)
STRUCT_FOR_ID(n_unnamed_fields)
@ -607,7 +604,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(name_from)
STRUCT_FOR_ID(namespace_separator)
STRUCT_FOR_ID(namespaces)
STRUCT_FOR_ID(narg)
STRUCT_FOR_ID(ndigits)
STRUCT_FOR_ID(nested)
STRUCT_FOR_ID(new_file_name)
@ -665,7 +661,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(print_file_and_line)
STRUCT_FOR_ID(priority)
STRUCT_FOR_ID(progress)
STRUCT_FOR_ID(progress_handler)
STRUCT_FOR_ID(progress_routine)
STRUCT_FOR_ID(proto)
STRUCT_FOR_ID(protocol)
@ -771,7 +766,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(timetuple)
STRUCT_FOR_ID(timeunit)
STRUCT_FOR_ID(top)
STRUCT_FOR_ID(trace_callback)
STRUCT_FOR_ID(traceback)
STRUCT_FOR_ID(trailers)
STRUCT_FOR_ID(translate)

View file

@ -790,7 +790,6 @@ extern "C" {
INIT_ID(add_done_callback), \
INIT_ID(after_in_child), \
INIT_ID(after_in_parent), \
INIT_ID(aggregate_class), \
INIT_ID(alias), \
INIT_ID(align), \
INIT_ID(all), \
@ -807,7 +806,6 @@ extern "C" {
INIT_ID(ast), \
INIT_ID(athrow), \
INIT_ID(attribute), \
INIT_ID(authorizer_callback), \
INIT_ID(autocommit), \
INIT_ID(backtick), \
INIT_ID(base), \
@ -1106,7 +1104,6 @@ extern "C" {
INIT_ID(msg), \
INIT_ID(mutex), \
INIT_ID(mycmp), \
INIT_ID(n_arg), \
INIT_ID(n_fields), \
INIT_ID(n_sequence_fields), \
INIT_ID(n_unnamed_fields), \
@ -1114,7 +1111,6 @@ extern "C" {
INIT_ID(name_from), \
INIT_ID(namespace_separator), \
INIT_ID(namespaces), \
INIT_ID(narg), \
INIT_ID(ndigits), \
INIT_ID(nested), \
INIT_ID(new_file_name), \
@ -1172,7 +1168,6 @@ extern "C" {
INIT_ID(print_file_and_line), \
INIT_ID(priority), \
INIT_ID(progress), \
INIT_ID(progress_handler), \
INIT_ID(progress_routine), \
INIT_ID(proto), \
INIT_ID(protocol), \
@ -1278,7 +1273,6 @@ extern "C" {
INIT_ID(timetuple), \
INIT_ID(timeunit), \
INIT_ID(top), \
INIT_ID(trace_callback), \
INIT_ID(traceback), \
INIT_ID(trailers), \
INIT_ID(translate), \

View file

@ -920,10 +920,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(aggregate_class);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(alias);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
@ -988,10 +984,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(authorizer_callback);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(autocommit);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
@ -2184,10 +2176,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(n_arg);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(n_fields);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
@ -2216,10 +2204,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(narg);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(ndigits);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
@ -2448,10 +2432,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(progress_handler);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(progress_routine);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
@ -2872,10 +2852,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(trace_callback);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(traceback);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));

View file

@ -550,17 +550,9 @@ class ConnectionTests(unittest.TestCase):
cx.execute("insert into u values(0)")
def test_connect_positional_arguments(self):
regex = (
r"Passing more than 1 positional argument to sqlite3.connect\(\)"
" is deprecated. Parameters 'timeout', 'detect_types', "
"'isolation_level', 'check_same_thread', 'factory', "
"'cached_statements' and 'uri' will become keyword-only "
"parameters in Python 3.15."
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
cx = sqlite.connect(":memory:", 1.0)
cx.close()
self.assertEqual(cm.filename, __file__)
with self.assertRaisesRegex(TypeError,
r'connect\(\) takes at most 1 positional arguments'):
sqlite.connect(":memory:", 1.0)
def test_connection_resource_warning(self):
with self.assertWarns(ResourceWarning):

View file

@ -71,18 +71,9 @@ class ConnectionFactoryTests(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Factory, self).__init__(*args, **kwargs)
regex = (
r"Passing more than 1 positional argument to _sqlite3.Connection\(\) "
r"is deprecated. Parameters 'timeout', 'detect_types', "
r"'isolation_level', 'check_same_thread', 'factory', "
r"'cached_statements' and 'uri' will become keyword-only "
r"parameters in Python 3.15."
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
with memory_database(5.0, 0, None, True, Factory) as con:
self.assertIsNone(con.isolation_level)
self.assertIsInstance(con, Factory)
self.assertEqual(cm.filename, __file__)
with self.assertRaisesRegex(TypeError,
r'connect\(\) takes at most 1 positional arguments'):
memory_database(5.0, 0, None, True, Factory)
class CursorFactoryTests(MemoryDatabaseMixin, unittest.TestCase):

View file

@ -220,16 +220,9 @@ class ProgressTests(MemoryDatabaseMixin, unittest.TestCase):
""")
def test_progress_handler_keyword_args(self):
regex = (
r"Passing keyword argument 'progress_handler' to "
r"_sqlite3.Connection.set_progress_handler\(\) is deprecated. "
r"Parameter 'progress_handler' will become positional-only in "
r"Python 3.15."
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
with self.assertRaisesRegex(TypeError,
'takes at least 1 positional argument'):
self.con.set_progress_handler(progress_handler=lambda: None, n=1)
self.assertEqual(cm.filename, __file__)
class TraceCallbackTests(MemoryDatabaseMixin, unittest.TestCase):
@ -353,16 +346,9 @@ class TraceCallbackTests(MemoryDatabaseMixin, unittest.TestCase):
cx.execute("select 1")
def test_trace_keyword_args(self):
regex = (
r"Passing keyword argument 'trace_callback' to "
r"_sqlite3.Connection.set_trace_callback\(\) is deprecated. "
r"Parameter 'trace_callback' will become positional-only in "
r"Python 3.15."
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
with self.assertRaisesRegex(TypeError,
'takes exactly 1 positional argument'):
self.con.set_trace_callback(trace_callback=lambda: None)
self.assertEqual(cm.filename, __file__)
if __name__ == "__main__":

View file

@ -422,27 +422,9 @@ class FunctionTests(unittest.TestCase):
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__)
with self.assertRaisesRegex(TypeError,
'takes exactly 3 positional arguments'):
self.con.create_function("noop", 0, func=lambda: None)
class WindowSumInt:
@ -737,25 +719,9 @@ class AggregateTests(unittest.TestCase):
self.assertEqual(val, txt)
def test_agg_keyword_args(self):
regex = (
r"Passing keyword arguments 'name', 'n_arg' and 'aggregate_class' to "
r"_sqlite3.Connection.create_aggregate\(\) is deprecated. "
r"Parameters 'name', 'n_arg' and 'aggregate_class' will become "
r"positional-only in Python 3.15."
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
with self.assertRaisesRegex(TypeError,
'takes exactly 3 positional arguments'):
self.con.create_aggregate("test", 1, aggregate_class=AggrText)
self.assertEqual(cm.filename, __file__)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
self.con.create_aggregate("test", n_arg=1, aggregate_class=AggrText)
self.assertEqual(cm.filename, __file__)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
self.con.create_aggregate(name="test", n_arg=0,
aggregate_class=AggrText)
self.assertEqual(cm.filename, __file__)
class AuthorizerTests(unittest.TestCase):
@ -800,16 +766,9 @@ class AuthorizerTests(unittest.TestCase):
self.con.execute("select c2 from t1")
def test_authorizer_keyword_args(self):
regex = (
r"Passing keyword argument 'authorizer_callback' to "
r"_sqlite3.Connection.set_authorizer\(\) is deprecated. "
r"Parameter 'authorizer_callback' will become positional-only in "
r"Python 3.15."
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
with self.assertRaisesRegex(TypeError,
'takes exactly 1 positional argument'):
self.con.set_authorizer(authorizer_callback=lambda: None)
self.assertEqual(cm.filename, __file__)
class AuthorizerRaiseExceptionTests(AuthorizerTests):

View file

@ -0,0 +1,7 @@
Clean up :class:`sqlite3.Connection` APIs. All parameters of
:func:`sqlite3.connect` except *database* are now keyword-only. The first
three parameters of methods :meth:`~sqlite3.Connection.create_function` and
:meth:`~sqlite3.Connection.create_aggregate` are now positional-only. The
first parameter of methods :meth:`~sqlite3.Connection.set_authorizer`,
:meth:`~sqlite3.Connection.set_progress_handler` and
:meth:`~sqlite3.Connection.set_trace_callback` is now positional-only.

View file

@ -9,23 +9,17 @@ preserve
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
PyDoc_STRVAR(pysqlite_connect__doc__,
"connect($module, /, database, timeout=5.0, detect_types=0,\n"
"connect($module, /, database, *, timeout=5.0, detect_types=0,\n"
" isolation_level=\'\', check_same_thread=True,\n"
" factory=ConnectionType, cached_statements=128, uri=False, *,\n"
" factory=ConnectionType, cached_statements=128, uri=False,\n"
" autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL)\n"
"--\n"
"\n"
"Open a connection to the SQLite database file \'database\'.\n"
"\n"
"You can use \":memory:\" to open a database connection to a database that\n"
"resides in RAM instead of on disk.\n"
"\n"
"Note: Passing more than 1 positional argument to _sqlite3.connect() is\n"
"deprecated. Parameters \'timeout\', \'detect_types\', \'isolation_level\',\n"
"\'check_same_thread\', \'factory\', \'cached_statements\' and \'uri\' will\n"
"become keyword-only parameters in Python 3.15.\n"
"");
"resides in RAM instead of on disk.");
#define PYSQLITE_CONNECT_METHODDEF \
{"connect", _PyCFunction_CAST(pysqlite_connect), METH_FASTCALL|METH_KEYWORDS, pysqlite_connect__doc__},
/*[clinic end generated code: output=69b9b00da71c3c0a input=a9049054013a1b77]*/
/*[clinic end generated code: output=3d83139ba65e0bb5 input=a9049054013a1b77]*/

View file

@ -16,17 +16,6 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
int cache_size, int uri,
enum autocommit_mode autocommit);
// Emit compiler warnings when we get to Python 3.15.
#if PY_VERSION_HEX >= 0x030f00C0
# error "Update the clinic input of '_sqlite3.Connection.__init__'."
#elif PY_VERSION_HEX >= 0x030f00A0
# ifdef _MSC_VER
# pragma message ("Update the clinic input of '_sqlite3.Connection.__init__'.")
# else
# warning "Update the clinic input of '_sqlite3.Connection.__init__'."
# endif
#endif
static int
pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
@ -72,25 +61,14 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
int uri = 0;
enum autocommit_mode autocommit = LEGACY_TRANSACTION_CONTROL;
if (nargs > 1 && nargs <= 8) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing more than 1 positional argument to _sqlite3.Connection()"
" is deprecated. Parameters 'timeout', 'detect_types', "
"'isolation_level', 'check_same_thread', 'factory', "
"'cached_statements' and 'uri' will become keyword-only "
"parameters in Python 3.15.", 1))
{
goto exit;
}
}
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
/*minpos*/ 1, /*maxpos*/ 8, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
if (!fastargs) {
goto exit;
}
database = fastargs[0];
if (!noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
if (fastargs[1]) {
if (PyFloat_CheckExact(fastargs[1])) {
@ -104,7 +82,7 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
if (fastargs[2]) {
@ -113,7 +91,7 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
if (fastargs[3]) {
@ -121,7 +99,7 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
if (fastargs[4]) {
@ -130,13 +108,13 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
if (fastargs[5]) {
factory = fastargs[5];
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
if (fastargs[6]) {
@ -145,7 +123,7 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
if (fastargs[7]) {
@ -154,13 +132,9 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
if (!--noptargs) {
goto skip_optional_pos;
goto skip_optional_kwonly;
}
}
skip_optional_pos:
if (!noptargs) {
goto skip_optional_kwonly;
}
if (!autocommit_converter(fastargs[8], &autocommit)) {
goto exit;
}
@ -424,15 +398,10 @@ pysqlite_connection_rollback(PyObject *self, PyObject *Py_UNUSED(ignored))
}
PyDoc_STRVAR(pysqlite_connection_create_function__doc__,
"create_function($self, /, name, narg, func, *, deterministic=False)\n"
"create_function($self, name, narg, func, /, *, deterministic=False)\n"
"--\n"
"\n"
"Creates a new function.\n"
"\n"
"Note: Passing keyword arguments \'name\', \'narg\' and \'func\' to\n"
"_sqlite3.Connection.create_function() is deprecated. Parameters\n"
"\'name\', \'narg\' and \'func\' will become positional-only in Python 3.15.\n"
"");
"Creates a new function.");
#define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF \
{"create_function", _PyCFunction_CAST(pysqlite_connection_create_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},
@ -443,24 +412,13 @@ pysqlite_connection_create_function_impl(pysqlite_Connection *self,
int narg, PyObject *func,
int deterministic);
// Emit compiler warnings when we get to Python 3.15.
#if PY_VERSION_HEX >= 0x030f00C0
# error "Update the clinic input of '_sqlite3.Connection.create_function'."
#elif PY_VERSION_HEX >= 0x030f00A0
# ifdef _MSC_VER
# pragma message ("Update the clinic input of '_sqlite3.Connection.create_function'.")
# else
# warning "Update the clinic input of '_sqlite3.Connection.create_function'."
# endif
#endif
static PyObject *
pysqlite_connection_create_function(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 4
#define NUM_KEYWORDS 1
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
@ -469,7 +427,7 @@ pysqlite_connection_create_function(PyObject *self, PyTypeObject *cls, PyObject
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_hash = -1,
.ob_item = { &_Py_ID(name), &_Py_ID(narg), &_Py_ID(func), &_Py_ID(deterministic), },
.ob_item = { &_Py_ID(deterministic), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
@ -478,7 +436,7 @@ pysqlite_connection_create_function(PyObject *self, PyTypeObject *cls, PyObject
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
static const char * const _keywords[] = {"name", "narg", "func", "deterministic", NULL};
static const char * const _keywords[] = {"", "", "", "deterministic", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "create_function",
@ -497,18 +455,8 @@ pysqlite_connection_create_function(PyObject *self, PyTypeObject *cls, PyObject
if (!args) {
goto exit;
}
if (nargs < 3) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing keyword arguments 'name', 'narg' and 'func' to "
"_sqlite3.Connection.create_function() is deprecated. Parameters "
"'name', 'narg' and 'func' will become positional-only in Python "
"3.15.", 1))
{
goto exit;
}
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("create_function", "argument 'name'", "str", args[0]);
_PyArg_BadArgument("create_function", "argument 1", "str", args[0]);
goto exit;
}
Py_ssize_t name_length;
@ -618,16 +566,10 @@ exit:
#endif /* defined(HAVE_WINDOW_FUNCTIONS) */
PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__,
"create_aggregate($self, /, name, n_arg, aggregate_class)\n"
"create_aggregate($self, name, n_arg, aggregate_class, /)\n"
"--\n"
"\n"
"Creates a new aggregate.\n"
"\n"
"Note: Passing keyword arguments \'name\', \'n_arg\' and \'aggregate_class\'\n"
"to _sqlite3.Connection.create_aggregate() is deprecated. Parameters\n"
"\'name\', \'n_arg\' and \'aggregate_class\' will become positional-only in\n"
"Python 3.15.\n"
"");
"Creates a new aggregate.");
#define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF \
{"create_aggregate", _PyCFunction_CAST(pysqlite_connection_create_aggregate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},
@ -638,42 +580,17 @@ pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
const char *name, int n_arg,
PyObject *aggregate_class);
// Emit compiler warnings when we get to Python 3.15.
#if PY_VERSION_HEX >= 0x030f00C0
# error "Update the clinic input of '_sqlite3.Connection.create_aggregate'."
#elif PY_VERSION_HEX >= 0x030f00A0
# ifdef _MSC_VER
# pragma message ("Update the clinic input of '_sqlite3.Connection.create_aggregate'.")
# else
# warning "Update the clinic input of '_sqlite3.Connection.create_aggregate'."
# endif
#endif
static PyObject *
pysqlite_connection_create_aggregate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 3
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
Py_hash_t ob_hash;
PyObject *ob_item[NUM_KEYWORDS];
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_hash = -1,
.ob_item = { &_Py_ID(name), &_Py_ID(n_arg), &_Py_ID(aggregate_class), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
#else // !Py_BUILD_CORE
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
#else
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
#endif
static const char * const _keywords[] = {"name", "n_arg", "aggregate_class", NULL};
static const char * const _keywords[] = {"", "", "", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "create_aggregate",
@ -690,18 +607,8 @@ pysqlite_connection_create_aggregate(PyObject *self, PyTypeObject *cls, PyObject
if (!args) {
goto exit;
}
if (nargs < 3) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing keyword arguments 'name', 'n_arg' and 'aggregate_class' "
"to _sqlite3.Connection.create_aggregate() is deprecated. "
"Parameters 'name', 'n_arg' and 'aggregate_class' will become "
"positional-only in Python 3.15.", 1))
{
goto exit;
}
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args[0]);
_PyArg_BadArgument("create_aggregate", "argument 1", "str", args[0]);
goto exit;
}
Py_ssize_t name_length;
@ -725,15 +632,10 @@ exit:
}
PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,
"set_authorizer($self, /, authorizer_callback)\n"
"set_authorizer($self, authorizer_callback, /)\n"
"--\n"
"\n"
"Set authorizer callback.\n"
"\n"
"Note: Passing keyword argument \'authorizer_callback\' to\n"
"_sqlite3.Connection.set_authorizer() is deprecated. Parameter\n"
"\'authorizer_callback\' will become positional-only in Python 3.15.\n"
"");
"Set authorizer callback.");
#define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \
{"set_authorizer", _PyCFunction_CAST(pysqlite_connection_set_authorizer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},
@ -743,42 +645,17 @@ pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable);
// Emit compiler warnings when we get to Python 3.15.
#if PY_VERSION_HEX >= 0x030f00C0
# error "Update the clinic input of '_sqlite3.Connection.set_authorizer'."
#elif PY_VERSION_HEX >= 0x030f00A0
# ifdef _MSC_VER
# pragma message ("Update the clinic input of '_sqlite3.Connection.set_authorizer'.")
# else
# warning "Update the clinic input of '_sqlite3.Connection.set_authorizer'."
# endif
#endif
static PyObject *
pysqlite_connection_set_authorizer(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 1
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
Py_hash_t ob_hash;
PyObject *ob_item[NUM_KEYWORDS];
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_hash = -1,
.ob_item = { &_Py_ID(authorizer_callback), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
#else // !Py_BUILD_CORE
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
#else
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
#endif
static const char * const _keywords[] = {"authorizer_callback", NULL};
static const char * const _keywords[] = {"", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "set_authorizer",
@ -793,16 +670,6 @@ pysqlite_connection_set_authorizer(PyObject *self, PyTypeObject *cls, PyObject *
if (!args) {
goto exit;
}
if (nargs < 1) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing keyword argument 'authorizer_callback' to "
"_sqlite3.Connection.set_authorizer() is deprecated. Parameter "
"'authorizer_callback' will become positional-only in Python "
"3.15.", 1))
{
goto exit;
}
}
callable = args[0];
return_value = pysqlite_connection_set_authorizer_impl((pysqlite_Connection *)self, cls, callable);
@ -811,7 +678,7 @@ exit:
}
PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
"set_progress_handler($self, /, progress_handler, n)\n"
"set_progress_handler($self, progress_handler, /, n)\n"
"--\n"
"\n"
"Set progress handler callback.\n"
@ -824,12 +691,7 @@ PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
" The number of SQLite virtual machine instructions that are\n"
" executed between invocations of \'progress_handler\'.\n"
"\n"
"If \'progress_handler\' is None or \'n\' is 0, the progress handler is disabled.\n"
"\n"
"Note: Passing keyword argument \'progress_handler\' to\n"
"_sqlite3.Connection.set_progress_handler() is deprecated. Parameter\n"
"\'progress_handler\' will become positional-only in Python 3.15.\n"
"");
"If \'progress_handler\' is None or \'n\' is 0, the progress handler is disabled.");
#define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF \
{"set_progress_handler", _PyCFunction_CAST(pysqlite_connection_set_progress_handler), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},
@ -839,24 +701,13 @@ pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable, int n);
// Emit compiler warnings when we get to Python 3.15.
#if PY_VERSION_HEX >= 0x030f00C0
# error "Update the clinic input of '_sqlite3.Connection.set_progress_handler'."
#elif PY_VERSION_HEX >= 0x030f00A0
# ifdef _MSC_VER
# pragma message ("Update the clinic input of '_sqlite3.Connection.set_progress_handler'.")
# else
# warning "Update the clinic input of '_sqlite3.Connection.set_progress_handler'."
# endif
#endif
static PyObject *
pysqlite_connection_set_progress_handler(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 2
#define NUM_KEYWORDS 1
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
@ -865,7 +716,7 @@ pysqlite_connection_set_progress_handler(PyObject *self, PyTypeObject *cls, PyOb
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_hash = -1,
.ob_item = { &_Py_ID(progress_handler), _Py_LATIN1_CHR('n'), },
.ob_item = { _Py_LATIN1_CHR('n'), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
@ -874,7 +725,7 @@ pysqlite_connection_set_progress_handler(PyObject *self, PyTypeObject *cls, PyOb
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
static const char * const _keywords[] = {"progress_handler", "n", NULL};
static const char * const _keywords[] = {"", "n", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "set_progress_handler",
@ -890,16 +741,6 @@ pysqlite_connection_set_progress_handler(PyObject *self, PyTypeObject *cls, PyOb
if (!args) {
goto exit;
}
if (nargs < 1) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing keyword argument 'progress_handler' to "
"_sqlite3.Connection.set_progress_handler() is deprecated. "
"Parameter 'progress_handler' will become positional-only in "
"Python 3.15.", 1))
{
goto exit;
}
}
callable = args[0];
n = PyLong_AsInt(args[1]);
if (n == -1 && PyErr_Occurred()) {
@ -912,15 +753,10 @@ exit:
}
PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__,
"set_trace_callback($self, /, trace_callback)\n"
"set_trace_callback($self, trace_callback, /)\n"
"--\n"
"\n"
"Set a trace callback called for each SQL statement (passed as unicode).\n"
"\n"
"Note: Passing keyword argument \'trace_callback\' to\n"
"_sqlite3.Connection.set_trace_callback() is deprecated. Parameter\n"
"\'trace_callback\' will become positional-only in Python 3.15.\n"
"");
"Set a trace callback called for each SQL statement (passed as unicode).");
#define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF \
{"set_trace_callback", _PyCFunction_CAST(pysqlite_connection_set_trace_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},
@ -930,42 +766,17 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable);
// Emit compiler warnings when we get to Python 3.15.
#if PY_VERSION_HEX >= 0x030f00C0
# error "Update the clinic input of '_sqlite3.Connection.set_trace_callback'."
#elif PY_VERSION_HEX >= 0x030f00A0
# ifdef _MSC_VER
# pragma message ("Update the clinic input of '_sqlite3.Connection.set_trace_callback'.")
# else
# warning "Update the clinic input of '_sqlite3.Connection.set_trace_callback'."
# endif
#endif
static PyObject *
pysqlite_connection_set_trace_callback(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 1
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
Py_hash_t ob_hash;
PyObject *ob_item[NUM_KEYWORDS];
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_hash = -1,
.ob_item = { &_Py_ID(trace_callback), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
#else // !Py_BUILD_CORE
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
#else
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
#endif
static const char * const _keywords[] = {"trace_callback", NULL};
static const char * const _keywords[] = {"", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "set_trace_callback",
@ -980,16 +791,6 @@ pysqlite_connection_set_trace_callback(PyObject *self, PyTypeObject *cls, PyObje
if (!args) {
goto exit;
}
if (nargs < 1) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing keyword argument 'trace_callback' to "
"_sqlite3.Connection.set_trace_callback() is deprecated. "
"Parameter 'trace_callback' will become positional-only in Python"
" 3.15.", 1))
{
goto exit;
}
}
callable = args[0];
return_value = pysqlite_connection_set_trace_callback_impl((pysqlite_Connection *)self, cls, callable);
@ -1921,4 +1722,4 @@ exit:
#ifndef DESERIALIZE_METHODDEF
#define DESERIALIZE_METHODDEF
#endif /* !defined(DESERIALIZE_METHODDEF) */
/*[clinic end generated code: output=2f325c2444b4bb47 input=a9049054013a1b77]*/
/*[clinic end generated code: output=6cb96e557133d553 input=a9049054013a1b77]*/

View file

@ -215,7 +215,7 @@ class sqlite3_int64_converter(CConverter):
_sqlite3.Connection.__init__ as pysqlite_connection_init
database: object
* [from 3.15]
*
timeout: double = 5.0
detect_types: int = 0
isolation_level: IsolationLevel = ""
@ -223,7 +223,6 @@ _sqlite3.Connection.__init__ as pysqlite_connection_init
factory: object(c_default='(PyObject*)clinic_state()->ConnectionType') = ConnectionType
cached_statements as cache_size: int = 128
uri: bool = False
*
autocommit: Autocommit(c_default='LEGACY_TRANSACTION_CONTROL') = sqlite3.LEGACY_TRANSACTION_CONTROL
[clinic start generated code]*/
@ -234,7 +233,7 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
int check_same_thread, PyObject *factory,
int cache_size, int uri,
enum autocommit_mode autocommit)
/*[clinic end generated code: output=cba057313ea7712f input=219c3dbecbae7d99]*/
/*[clinic end generated code: output=cba057313ea7712f input=5ca4883d8747a49b]*/
{
if (PySys_Audit("sqlite3.connect", "O", database) < 0) {
return -1;
@ -1158,11 +1157,10 @@ check_num_params(pysqlite_Connection *self, const int n, const char *name)
_sqlite3.Connection.create_function as pysqlite_connection_create_function
cls: defining_class
/
name: str
narg: int
func: object
/ [from 3.15]
/
*
deterministic: bool = False
@ -1174,7 +1172,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=c7c313b0ca8b519e]*/
/*[clinic end generated code: output=8a811529287ad240 input=a896096ed5390ae1]*/
{
int rc;
int flags = SQLITE_UTF8;
@ -1366,11 +1364,10 @@ create_window_function_impl(pysqlite_Connection *self, PyTypeObject *cls,
_sqlite3.Connection.create_aggregate as pysqlite_connection_create_aggregate
cls: defining_class
/
name: str
n_arg: int
aggregate_class: object
/ [from 3.15]
/
Creates a new aggregate.
[clinic start generated code]*/
@ -1380,7 +1377,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=8087056db6eae1cf]*/
/*[clinic end generated code: output=1b02d0f0aec7ff96 input=aa2773f6a42f7e17]*/
{
int rc;
@ -1531,7 +1528,7 @@ _sqlite3.Connection.set_authorizer as pysqlite_connection_set_authorizer
cls: defining_class
authorizer_callback as callable: object
/ [from 3.15]
/
Set authorizer callback.
[clinic start generated code]*/
@ -1540,7 +1537,7 @@ static PyObject *
pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable)
/*[clinic end generated code: output=75fa60114fc971c3 input=a52bd4937c588752]*/
/*[clinic end generated code: output=75fa60114fc971c3 input=e76469ab0bb1bbcd]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
@ -1576,7 +1573,7 @@ _sqlite3.Connection.set_progress_handler as pysqlite_connection_set_progress_han
A callable that takes no arguments.
If the callable returns non-zero, the current query is terminated,
and an exception is raised.
/ [from 3.15]
/
n: int
The number of SQLite virtual machine instructions that are
executed between invocations of 'progress_handler'.
@ -1590,7 +1587,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=b4d6e2ef8b4d32f9]*/
/*[clinic end generated code: output=0739957fd8034a50 input=74c943f1ae7d8880]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
@ -1617,7 +1614,7 @@ _sqlite3.Connection.set_trace_callback as pysqlite_connection_set_trace_callback
cls: defining_class
trace_callback as callable: object
/ [from 3.15]
/
Set a trace callback called for each SQL statement (passed as unicode).
[clinic start generated code]*/
@ -1626,7 +1623,7 @@ static PyObject *
pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
PyTypeObject *cls,
PyObject *callable)
/*[clinic end generated code: output=d91048c03bfcee05 input=d705d592ec03cf28]*/
/*[clinic end generated code: output=d91048c03bfcee05 input=f4f59bf2f87f2026]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;

View file

@ -60,26 +60,16 @@ pysqlite_connect(PyObject *module, PyObject *const *args, Py_ssize_t nargsf,
pysqlite_state *state = pysqlite_get_state(module);
PyObject *factory = (PyObject *)state->ConnectionType;
static const int FACTORY_POS = 5;
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
if (nargs > 1 && nargs <= 8) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"Passing more than 1 positional argument to sqlite3.connect()"
" is deprecated. Parameters 'timeout', 'detect_types', "
"'isolation_level', 'check_same_thread', 'factory', "
"'cached_statements' and 'uri' will become keyword-only "
"parameters in Python 3.15.", 1))
{
return NULL;
}
if (nargs > 1) {
PyErr_Format(PyExc_TypeError,
"connect() takes at most 1 positional arguments (%zd given)", nargs);
return NULL;
}
if (nargs > FACTORY_POS) {
factory = args[FACTORY_POS];
}
else if (kwnames != NULL) {
if (kwnames != NULL) {
for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(kwnames); i++) {
PyObject *item = PyTuple_GET_ITEM(kwnames, i); // borrowed ref.
if (PyUnicode_CompareWithASCIIString(item, "factory") == 0) {
if (PyUnicode_EqualToUTF8(item, "factory")) {
factory = args[nargs + i];
break;
}

View file

@ -3,7 +3,6 @@
# Keep lines sorted lexicographically to help avoid merge conflicts.
# Format example:
# /path/to/file (number of warnings in file)
Modules/_sqlite/clinic/connection.c.h 6
Modules/expat/siphash.h 7
Modules/expat/xmlparse.c 13
Modules/expat/xmltok.c 3

View file

@ -3,4 +3,3 @@
# Keep lines sorted lexicographically to help avoid merge conflicts.
# Format example:
# /path/to/file (number of warnings in file)
Modules/_sqlite/clinic/connection.c.h 6