summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2024-04-30 19:58:22 (GMT)
committerGitHub <noreply@github.com>2024-04-30 19:58:22 (GMT)
commitb568c2c1ff5c0b1922a6402dc95c588d7f9aa914 (patch)
tree60e2a34278a62d8a29da66a51f009a3a60b9830f
parent19d468a3ab1d57c07a4283d67d439908574aa0cc (diff)
downloadcpython-b568c2c1ff5c0b1922a6402dc95c588d7f9aa914.zip
cpython-b568c2c1ff5c0b1922a6402dc95c588d7f9aa914.tar.gz
cpython-b568c2c1ff5c0b1922a6402dc95c588d7f9aa914.tar.bz2
gh-118406: Add signature for sqlite3.Connection objects (#118428)
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py5
-rw-r--r--Misc/NEWS.d/next/Library/2024-04-30-15-18-19.gh-issue-118406.y-GnMo.rst1
-rw-r--r--Modules/_sqlite/connection.c7
3 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 6d8744c..51ce095 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -590,6 +590,11 @@ class ConnectionTests(unittest.TestCase):
del cx
gc_collect()
+ def test_connection_signature(self):
+ from inspect import signature
+ sig = signature(self.cx)
+ self.assertEqual(str(sig), "(sql, /)")
+
class UninitialisedConnectionTests(unittest.TestCase):
def setUp(self):
diff --git a/Misc/NEWS.d/next/Library/2024-04-30-15-18-19.gh-issue-118406.y-GnMo.rst b/Misc/NEWS.d/next/Library/2024-04-30-15-18-19.gh-issue-118406.y-GnMo.rst
new file mode 100644
index 0000000..c60ddf9
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-04-30-15-18-19.gh-issue-118406.y-GnMo.rst
@@ -0,0 +1 @@
+Add signature for :class:`sqlite3.Connection` objects.
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 74984ca..fc03e4a 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -2561,6 +2561,12 @@ set_autocommit(pysqlite_Connection *self, PyObject *val, void *Py_UNUSED(ctx))
return 0;
}
+static PyObject *
+get_sig(PyObject *self, void *Py_UNUSED(ctx))
+{
+ return PyUnicode_FromString("(sql, /)");
+}
+
static const char connection_doc[] =
PyDoc_STR("SQLite database connection object.");
@@ -2570,6 +2576,7 @@ static PyGetSetDef connection_getset[] = {
{"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)0},
{"in_transaction", (getter)pysqlite_connection_get_in_transaction, (setter)0},
{"autocommit", (getter)get_autocommit, (setter)set_autocommit},
+ {"__text_signature__", get_sig, (setter)0},
{NULL}
};