bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567)
This commit is contained in:
parent
185ecdc146
commit
7d0a47e1af
@ -26,6 +26,7 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from test.support import check_disallow_instantiation
|
||||||
from test.support.os_helper import TESTFN, unlink
|
from test.support.os_helper import TESTFN, unlink
|
||||||
from test.support import threading_helper
|
from test.support import threading_helper
|
||||||
|
|
||||||
@ -105,6 +106,10 @@ class ModuleTests(unittest.TestCase):
|
|||||||
sqlite.enable_shared_cache(enable)
|
sqlite.enable_shared_cache(enable)
|
||||||
self.assertIn("dbapi.py", cm.filename)
|
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):
|
class ConnectionTests(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ static PyType_Spec stmt_spec = {
|
|||||||
.name = MODULE_NAME ".Statement",
|
.name = MODULE_NAME ".Statement",
|
||||||
.basicsize = sizeof(pysqlite_Statement),
|
.basicsize = sizeof(pysqlite_Statement),
|
||||||
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
||||||
Py_TPFLAGS_IMMUTABLETYPE),
|
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION),
|
||||||
.slots = stmt_slots,
|
.slots = stmt_slots,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user