Bug report
Bug description:
Summary
sqlite3.Connection.execute() currently exposes this text signature:
execute($self, sql, parameters=<unrepresentable>, /)
As a result, inspect.signature(sqlite3.Connection.execute) raises
ValueError. The correct Python default is (), while the C wrapper must
continue using NULL when the argument is omitted.
Evidence
The current Clinic definition in Modules/_sqlite/connection.c is:
parameters: object = NULL
When the argument is omitted, _pysqlite_query_execute() explicitly converts
the C NULL sentinel to an empty tuple:
if (second_argument == NULL) {
second_argument = PyTuple_New(0);
}
Therefore these calls are equivalent:
con.execute("select 42")
con.execute("select 42", ())
The public documentation already specifies:
execute(sql, parameters=(), /)
sqlite3.Cursor.execute() also uses the correct Clinic pattern:
parameters: object(c_default="NULL") = ()
Reproduction
import inspect
import sqlite3
inspect.signature(sqlite3.Connection.execute)
# ValueError: builtin has invalid signature
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
Summary
sqlite3.Connection.execute()currently exposes this text signature:As a result,
inspect.signature(sqlite3.Connection.execute)raisesValueError. The correct Python default is(), while the C wrapper mustcontinue using
NULLwhen the argument is omitted.Evidence
The current Clinic definition in
Modules/_sqlite/connection.cis:When the argument is omitted,
_pysqlite_query_execute()explicitly convertsthe C
NULLsentinel to an empty tuple:Therefore these calls are equivalent:
The public documentation already specifies:
sqlite3.Cursor.execute()also uses the correct Clinic pattern:Reproduction
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
sqlite3.Connection.execute()#155953<unrepresentable>Argument Clinic defaults in several signatures #155954