8000 bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) · miss-islington/cpython@8756d86 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8756d86

Browse files
Erlend Egeberg Aaslandmiss-islington
authored andcommitted
bpo-44087: Disallow instantiation of sqlite3.Statement (pythonGH-26567)
(cherry picked from commit 7d0a47e) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
1 parent 344487b commit 8756d86

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/sqlite3/test/dbapi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import sqlite3 as sqlite
2626
import sys
2727

28+
from test.support import check_disallow_instantiation
2829
from test.support.os_helper import TESTFN, unlink
2930

3031

@@ -92,6 +93,10 @@ def test_shared_cache_deprecated(self):
9293
sqlite.enable_shared_cache(enable)
9394
self.assertIn("dbapi.py", cm.filename)
9495

96+
def test_disallow_instantiation(self):
97+
cx = sqlite.connect(":memory:")
98+
check_disallow_instantiation(self, type(cx("select 1")))
99+
95100

96101
class ConnectionTests(unittest.TestCase):
97102

Modules/_sqlite/statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static PyType_Spec stmt_spec = {
509509
.name = MODULE_NAME ".Statement",
510510
.basicsize = sizeof(pysqlite_Statement),
511511
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
512-
Py_TPFLAGS_IMMUTABLETYPE),
512+
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION),
513513
.slots = stmt_slots,
514514
};
515515
PyTypeObject *pysqlite_StatementType = NULL;

0 commit comments

Comments
 (0)
0