You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[sqlite3] consider adding Py_TPFLAGS_DISALLOW_INSTANTIATION to sqlite3.Statement #88253
Currently, the sqlite3.Statement type is not exposed in the module dict:
>>> import sqlite3
>>> sqlite3.Statement
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/sqlite3/__init__.py", line 37, in __getattr__
raise AttributeError(f"module 'sqlite3' has no attribute '{name}'")
AttributeError: module 'sqlite3' has no attribute 'Statement'
It is possible to extract it using this trick:
>>> cx = sqlite3.connect(":memory:")
>>> stmt = cx("select 1")
>>> type(stmt)
<class 'sqlite3.Statement'>
>>> type(stmt)()
<sqlite3.Statement object at 0x109006b30>
There is no use case for this; statement objects belong to the internal workings of the sqlite3 module. I suggest adding Py_TPFLAGS_DISALLOW_INSTANTIATION to make this fact more explicit.
New changeset ccc95c7 by Erlend Egeberg Aasland in branch '3.10':
[3.10] bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) (GH-26816) ccc95c7
Activity
erlend-aasland commentedon May 9, 2021
Currently, the sqlite3.Statement type is not exposed in the module dict:
There is no use case for this; statement objects belong to the internal workings of the sqlite3 module. I suggest adding Py_TPFLAGS_DISALLOW_INSTANTIATION to make this fact more explicit.
pablogsal commentedon Jun 20, 2021
New changeset 7d0a47e by Erlend Egeberg Aasland in branch 'main':
bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567)
7d0a47e
pablogsal commentedon Jun 20, 2021
New changeset ccc95c7 by Erlend Egeberg Aasland in branch '3.10':
[3.10] bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) (GH-26816)
ccc95c7