From a7bd24a7bc6abae5bbbfd20106f18a3462a18733 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sat, 30 May 2020 10:56:59 +0200 Subject: [PATCH 1/2] bpo-40810: Fix CheckTraceCallbackContent for SQLite pre 3.7.15 --- Lib/sqlite3/test/hooks.py | 4 ++++ .../next/Tests/2020-05-30-10-56-38.bpo-40810.LPqDLQ.rst | 1 + 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2020-05-30-10-56-38.bpo-40810.LPqDLQ.rst diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index d74e74bf272275..74761a96ca683f 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -265,6 +265,10 @@ def trace(statement): cur.execute(queries[0]) con2.execute("create table bar(x)") cur.execute(queries[1]) + + # See bpo-40810 + if sqlite.sqlite_version_info < (3, 7, 15): + queries.append(queries[-1]) self.assertEqual(traced_statements, queries) diff --git a/Misc/NEWS.d/next/Tests/2020-05-30-10-56-38.bpo-40810.LPqDLQ.rst b/Misc/NEWS.d/next/Tests/2020-05-30-10-56-38.bpo-40810.LPqDLQ.rst new file mode 100644 index 00000000000000..1965ecd6ef511f --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-05-30-10-56-38.bpo-40810.LPqDLQ.rst @@ -0,0 +1 @@ +In :mod:`sqlite3`, fix `CheckTraceCallbackContent` for SQLite pre 3.7.15. From 24b9639bec274b19a47d0dae15c35e0115209d21 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sat, 30 May 2020 12:18:35 +0200 Subject: [PATCH 2/2] Improve comment --- Lib/sqlite3/test/hooks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index 74761a96ca683f..214205c1167a41 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -266,6 +266,10 @@ def trace(statement): con2.execute("create table bar(x)") cur.execute(queries[1]) + # Extract from SQLite 3.7.15 changelog: + # Avoid invoking the sqlite3_trace() callback multiple times when a + # statement is automatically reprepared due to SQLITE_SCHEMA errors. + # # See bpo-40810 if sqlite.sqlite_version_info < (3, 7, 15): queries.append(queries[-1])