From 647bb9cb7cb1a860e7333a1279ef33b68dc46aca Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 7 Jun 2021 00:48:00 +0200 Subject: [PATCH 1/2] bpo-44087: sqlite3.Statement uses Py_TPFLAGS_DISALLOW_INSTANTIATION --- Modules/_sqlite/statement.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 5c38b4607b428f..f4e4ae468b80c3 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -502,7 +502,8 @@ static PyType_Slot stmt_slots[] = { static PyType_Spec stmt_spec = { .name = MODULE_NAME ".Statement", .basicsize = sizeof(pysqlite_Statement), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_DISALLOW_INSTANTIATION), .slots = stmt_slots, }; PyTypeObject *pysqlite_StatementType = NULL; From 81fc38b6e8cf08670863a7b83f90f7be0c9bbcff Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 7 Jun 2021 00:53:19 +0200 Subject: [PATCH 2/2] Add test --- Lib/sqlite3/test/dbapi.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py index 4bda6aa393e3ff..e7382b34baf4ed 100644 --- a/Lib/sqlite3/test/dbapi.py +++ b/Lib/sqlite3/test/dbapi.py @@ -26,6 +26,7 @@ import threading import unittest +from test.support import check_disallow_instantiation from test.support.os_helper import TESTFN, unlink @@ -104,6 +105,10 @@ def test_shared_cache_deprecated(self): sqlite.enable_shared_cache(enable) self.assertIn("dbapi.py", cm.filename) + def test_disallow_instantiation(self): + cx = sqlite.connect(":memory:") + check_disallow_instantiation(self, type(cx("select 1"))) + class ConnectionTests(unittest.TestCase): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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