From 9819b6fc8e02d964911d391ef784eb0c9ada84d3 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 29 Aug 2020 16:45:18 +0300 Subject: [PATCH 1/2] bpo-41638: Improve ProgrammingError message for absent parameter. It contains now the name of the parameter instead of its index when parameters are supplied as a dict. --- .../next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst | 3 +++ Modules/_sqlite/statement.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst diff --git a/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst b/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst new file mode 100644 index 00000000000000..f49fd83b1a88dd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst @@ -0,0 +1,3 @@ +ProgrammingError message for absent parameter in :mod:`sqlite3` +contains now the name of the parameter instead of its index when parameters +are supplied as a dict. diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 9de8f9b67228f5..26599b423eb8b9 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -295,7 +295,7 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para Py_DECREF(binding_name_obj); if (!current_param) { if (!PyErr_Occurred() || PyErr_ExceptionMatches(PyExc_LookupError)) { - PyErr_Format(pysqlite_ProgrammingError, "You did not supply a value for binding %d.", i); + PyErr_Format(pysqlite_ProgrammingError, "You did not supply a value for binding parameter :%s.", binding_name); } return; } From 8d5f67e2ed653cfcd0a960b4f1a73488c9cb9475 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 30 Aug 2020 20:34:40 +0300 Subject: [PATCH 2/2] Update the NEWS entry. --- .../next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst b/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst index f49fd83b1a88dd..8ab7b5e9903dcb 100644 --- a/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst +++ b/Misc/NEWS.d/next/Library/2020-08-29-16-45-12.bpo-41638.iZfW5N.rst @@ -1,3 +1,3 @@ -ProgrammingError message for absent parameter in :mod:`sqlite3` +:exc:`~sqlite3.ProgrammingError` message for absent parameter in :mod:`sqlite3` contains now the name of the parameter instead of its index when parameters are supplied as a dict.