pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/101698.patch

s cm: - self.cu.executemany(query, [params]) - self.assertEqual(cm.filename, __file__) def test_execute_too_many_params(self): category = sqlite.SQLITE_LIMIT_VARIABLE_NUMBER From a18d0bb690aa8487d868b82493caa04f9729b33c Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 9 Feb 2023 12:15:55 +0100 Subject: [PATCH 06/12] Address review: add test for query with more than one named param --- Lib/test/test_sqlite3/test_dbapi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index ed792cf117fab7..695e213cdc7b75 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -867,6 +867,7 @@ def test_execute_named_param_and_sequence(self): ("select :a, ?, ?", (1, 2, 3)), ("select ?, :b, ?", (1, 2, 3)), ("select ?, ?, :c", (1, 2, 3)), + ("select :a, :b, ?", (1, 2, 3)), ) msg = "Binding.*is a named parameter" for query, params in dataset: From 3f942017124b88bfca6586f25b2aaa0691134b16 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 9 Feb 2023 12:21:33 +0100 Subject: [PATCH 07/12] Address review: add PyErr_WarnFormat error handling --- Modules/_sqlite/cursor.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 070df760f81553..6f7970cf8197a2 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -664,13 +664,15 @@ bind_parameters(pysqlite_state *state, pysqlite_Statement *self, for (i = 0; i < num_params; i++) { const char *name = sqlite3_bind_parameter_name(self->st, i+1); if (name != NULL) { - 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); + 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)) { From 450cdcc4af5caf9d7afd73341d817e3387839507 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 14 Feb 2023 13:03:17 +0100 Subject: [PATCH 08/12] Fixup --- Doc/library/sqlite3.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index c5a72cea4a36f9..6671e9f2f88acc 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1476,6 +1476,10 @@ Cursor objects If *sql* contains more than one SQL statement, or is not a DML statment. + :raises DeprecationWarning: + If :ref:`named placeholders ` are used + and the items in *parameters* are sequences. + Example: .. testcode:: sqlite3.cursor From 841e8a4609962468a375de44bfd84c410db47f89 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 14 Feb 2023 13:08:06 +0100 Subject: [PATCH 09/12] Apply Serhiy's suggestion --- Doc/library/sqlite3.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 6671e9f2f88acc..9b48b0eda735df 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1437,7 +1437,7 @@ Cursor objects :raises DeprecationWarning: If :ref:`named placeholders ` are used - and *parameters* is a sequence. + and *parameters* is a sequence instead of a :class:`dict`. If :attr:`~Connection.autocommit` is :data:`LEGACY_TRANSACTION_CONTROL`, @@ -1478,7 +1478,7 @@ Cursor objects :raises DeprecationWarning: If :ref:`named placeholders ` are used - and the items in *parameters* are sequences. + and the items in *parameters* are sequences instead of :class:`dict`\s. Example: From 38d11107c83b0433b182ee1e647b72ac50336d2a Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 14 Feb 2023 21:41:10 +0100 Subject: [PATCH 10/12] Address Alex's review --- Doc/library/sqlite3.rst | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 9b48b0eda735df..a2ee2924f625fc 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1435,10 +1435,6 @@ Cursor objects :raises ProgrammingError: If *sql* contains more than one SQL statement. - :raises DeprecationWarning: - If :ref:`named placeholders ` are used - and *parameters* is a sequence instead of a :class:`dict`. - If :attr:`~Connection.autocommit` is :data:`LEGACY_TRANSACTION_CONTROL`, :attr:`~Connection.isolation_level` is not ``None``, @@ -1448,10 +1444,9 @@ Cursor objects .. versionchanged:: 3.12 - :exc:`DeprecationWarning` is raised - if + :exc:`DeprecationWarning` is emitted if :ref:`named placeholders ` are used - and *parameters* is a sequence. + and *parameters* is a sequence instead of a :class:`dict`. Use :meth:`executescript` to execute multiple SQL statements. @@ -1476,10 +1471,6 @@ Cursor objects If *sql* contains more than one SQL statement, or is not a DML statment. - :raises DeprecationWarning: - If :ref:`named placeholders ` are used - and the items in *parameters* are sequences instead of :class:`dict`\s. - Example: .. testcode:: sqlite3.cursor @@ -1493,9 +1484,10 @@ Cursor objects .. versionchanged:: 3.12 - :exc:`DeprecationWarning` is raised if + :exc:`DeprecationWarning` is emitted if :ref:`named placeholders ` are used - and the items in *parameters* are sequences. + and the items in *parameters* are sequences + instead of :class:`dict`\s. .. method:: executescript(sql_script, /) From cf3cfc895a9cf15c549af24865ce945a447a6ed0 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 14 Feb 2023 22:27:59 +0100 Subject: [PATCH 11/12] Also amend NEWS and What's New --- Doc/whatsnew/3.12.rst | 4 ++-- .../Library/2023-02-08-18-20-58.gh-issue-101693.4_LPXj.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 3d98e5917d932c..c62f462a19a2df 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -415,9 +415,9 @@ Deprecated and tailor them to your needs. (Contributed by Erlend E. Aasland in :gh:`90016`.) -* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now raised +* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted when :ref:`named placeholders ` are used together with - parameters supplied as a :term:`sequence`. + parameters supplied as a :term:`sequence` instead of as a :class:`dict`. Starting from Python 3.14, using named placeholders with parameters supplied as a sequence will raise a :exc:`~sqlite3.ProgrammingError`. (Contributed by Erlend E. Aasland in :gh:`101698`.) diff --git a/Misc/NEWS.d/next/Library/2023-02-08-18-20-58.gh-issue-101693.4_LPXj.rst b/Misc/NEWS.d/next/Library/2023-02-08-18-20-58.gh-issue-101693.4_LPXj.rst index 23901a604ae241..e436054b15b657 100644 --- a/Misc/NEWS.d/next/Library/2023-02-08-18-20-58.gh-issue-101693.4_LPXj.rst +++ b/Misc/NEWS.d/next/Library/2023-02-08-18-20-58.gh-issue-101693.4_LPXj.rst @@ -1,6 +1,6 @@ -In :meth:`sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now raised +In :meth:`sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted when :ref:`named placeholders ` are used together with -parameters supplied as a :term:`sequence`. +parameters supplied as a :term:`sequence` instead of as a :class:`dict`. Starting from Python 3.14, using named placeholders with parameters supplied as a sequence will raise a :exc:`~sqlite3.ProgrammingError`. Patch by Erlend E. Aasland. From 1687b65fe6cf0c4bdfc7d16cd1efd859937427e5 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 14 Feb 2023 23:09:51 +0100 Subject: [PATCH 12/12] Use deprecated-removed --- Doc/library/sqlite3.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index a2ee2924f625fc..18d0a5e630f6a9 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1442,11 +1442,13 @@ Cursor objects and there is no open transaction, a transaction is implicitly opened before executing *sql*. - .. versionchanged:: 3.12 + .. deprecated-removed:: 3.12 3.14 :exc:`DeprecationWarning` is emitted if :ref:`named placeholders ` are used and *parameters* is a sequence instead of a :class:`dict`. + Starting with Python 3.14, :exc:`ProgrammingError` will + be raised instead. Use :meth:`executescript` to execute multiple SQL statements. @@ -1482,12 +1484,14 @@ Cursor objects # cur is an sqlite3.Cursor object cur.executemany("INSERT INTO data VALUES(?)", rows) - .. versionchanged:: 3.12 + .. deprecated-removed:: 3.12 3.14 :exc:`DeprecationWarning` is emitted if :ref:`named placeholders ` are used and the items in *parameters* are sequences instead of :class:`dict`\s. + Starting with Python 3.14, :exc:`ProgrammingError` will + be raised instead. .. method:: executescript(sql_script, /) pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy