[Python-checkins] gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570)

JelleZijlstra webhook-mailer at python.org
Fri Apr 15 12:25:12 EDT 2022


https://github.com/python/cpython/commit/d104f4d21f735693ea93fe65ea4b4e1aa1779343
commit: d104f4d21f735693ea93fe65ea4b4e1aa1779343
branch: main
author: Erlend Egeberg Aasland <erlend.aasland at innova.no>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-04-15T09:25:03-07:00
summary:

gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570)

files:
M Lib/test/test_sqlite3/test_dbapi.py
M Modules/_sqlite/blob.c

diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 6613d5f0ea4bd..b010813fff7c5 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -356,6 +356,7 @@ def test_shared_cache_deprecated(self):
     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 821295cee813f..c4f8be45b2f94 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,
 };
 



More information about the Python-checkins mailing list