Skip to content
Prev Previous commit
Next Next commit
Manually insert deprecation warning for sqlite3.connect
  • Loading branch information
erlend-aasland committed Aug 15, 2023
commit de7e87cc0733b90c2693becac059dd72b58e925a
11 changes: 11 additions & 0 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ pysqlite_connect(PyObject *module, PyObject *const *args, Py_ssize_t nargsf,

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 > FACTORY_POS) {
factory = args[FACTORY_POS];
}
Expand Down