mirror of https://github.com/python/cpython
gh-118406: Add signature for sqlite3.Connection objects (#118428)
This commit is contained in:
parent
19d468a3ab
commit
b568c2c1ff
|
@ -590,6 +590,11 @@ class ConnectionTests(unittest.TestCase):
|
||||||
del cx
|
del cx
|
||||||
gc_collect()
|
gc_collect()
|
||||||
|
|
||||||
|
def test_connection_signature(self):
|
||||||
|
from inspect import signature
|
||||||
|
sig = signature(self.cx)
|
||||||
|
self.assertEqual(str(sig), "(sql, /)")
|
||||||
|
|
||||||
|
|
||||||
class UninitialisedConnectionTests(unittest.TestCase):
|
class UninitialisedConnectionTests(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add signature for :class:`sqlite3.Connection` objects.
|
|
@ -2561,6 +2561,12 @@ set_autocommit(pysqlite_Connection *self, PyObject *val, void *Py_UNUSED(ctx))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
get_sig(PyObject *self, void *Py_UNUSED(ctx))
|
||||||
|
{
|
||||||
|
return PyUnicode_FromString("(sql, /)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char connection_doc[] =
|
static const char connection_doc[] =
|
||||||
PyDoc_STR("SQLite database connection object.");
|
PyDoc_STR("SQLite database connection object.");
|
||||||
|
@ -2570,6 +2576,7 @@ static PyGetSetDef connection_getset[] = {
|
||||||
{"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)0},
|
{"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)0},
|
||||||
{"in_transaction", (getter)pysqlite_connection_get_in_transaction, (setter)0},
|
{"in_transaction", (getter)pysqlite_connection_get_in_transaction, (setter)0},
|
||||||
{"autocommit", (getter)get_autocommit, (setter)set_autocommit},
|
{"autocommit", (getter)get_autocommit, (setter)set_autocommit},
|
||||||
|
{"__text_signature__", get_sig, (setter)0},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue