From d104f4d21f735693ea93fe65ea4b4e1aa1779343 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Fri, 15 Apr 2022 18:25:03 +0200 Subject: gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570) --- Lib/test/test_sqlite3/test_dbapi.py | 1 + Modules/_sqlite/blob.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 6613d5f..b010813 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -356,6 +356,7 @@ class ModuleTests(unittest.TestCase): def test_disallow_instantiation(self): cx = sqlite.connect(":memory:") check_disallow_instantiation(self, type(cx("select 1"))) + check_disallow_instantiation(self, sqlite.Blob) def test_complete_statement(self): self.assertFalse(sqlite.complete_statement("select t")) diff --git a/Modules/_sqlite/blob.c b/Modules/_sqlite/blob.c index 821295c..c4f8be4 100644 --- a/Modules/_sqlite/blob.c +++ b/Modules/_sqlite/blob.c @@ -334,7 +334,7 @@ static PyType_Spec blob_spec = { .name = MODULE_NAME ".Blob", .basicsize = sizeof(pysqlite_Blob), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_IMMUTABLETYPE), + Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION), .slots = blob_slots, }; -- cgit v0.12