From: Erlend Egeberg Aasland Date: Fri, 15 Apr 2022 16:25:03 +0000 (+0200) Subject: gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570) X-Git-Tag: v3.11.0b1~360 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d104f4d21f735693ea93fe65ea4b4e1aa1779343;p=thirdparty%2FPython%2Fcpython.git gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570) --- diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 6613d5f0ea4b..b010813fff7c 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 821295cee813..c4f8be45b2f9 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, };