diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-02-15 05:27:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 05:27:16 (GMT) |
commit | 8a2b7ee64d1bde762438b458ea7fe88f054a3a88 (patch) | |
tree | c39e476cd5b2cdd9c348acc60bc3574fc97a9385 /Modules/_sqlite | |
parent | d777790bab878b8d1a218a1a60894b2823485cca (diff) | |
download | cpython-8a2b7ee64d1bde762438b458ea7fe88f054a3a88.zip cpython-8a2b7ee64d1bde762438b458ea7fe88f054a3a88.tar.gz cpython-8a2b7ee64d1bde762438b458ea7fe88f054a3a88.tar.bz2 |
gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence (#101698)
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/cursor.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index a4e22bb..6f7970c 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -662,6 +662,19 @@ bind_parameters(pysqlite_state *state, pysqlite_Statement *self, return; } for (i = 0; i < num_params; i++) { + const char *name = sqlite3_bind_parameter_name(self->st, i+1); + if (name != NULL) { + int ret = PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "Binding %d ('%s') is a named parameter, but you " + "supplied a sequence which requires nameless (qmark) " + "placeholders. Starting with Python 3.14 an " + "sqlite3.ProgrammingError will be raised.", + i+1, name); + if (ret < 0) { + return; + } + } + if (PyTuple_CheckExact(parameters)) { PyObject *item = PyTuple_GET_ITEM(parameters, i); current_param = Py_NewRef(item); |