Skip to content

[sqlite3] consider adding Py_TPFLAGS_DISALLOW_INSTANTIATION to sqlite3.Statement #88253

Closed

Description

@erlend-aasland
BPO 44087
Nosy @berkerpeksag, @serhiy-storchaka, @pablogsal, @miss-islington, @erlend-aasland
PRs
  • bpo-44087: Disallow instantiation of sqlite3.Statement #26567
  • [3.10] bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) #26813
  • [3.10] bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) #26816
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-06-20.21:29:55.005>
    created_at = <Date 2021-05-09.08:28:09.445>
    labels = ['easy', 'type-feature']
    title = '[sqlite3] consider adding Py_TPFLAGS_DISALLOW_INSTANTIATION to sqlite3.Statement'
    updated_at = <Date 2021-06-20.21:29:55.005>
    user = 'https://github.com/erlend-aasland'

    bugs.python.org fields:

    activity = <Date 2021-06-20.21:29:55.005>
    actor = 'erlendaasland'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-20.21:29:55.005>
    closer = 'erlendaasland'
    components = []
    creation = <Date 2021-05-09.08:28:09.445>
    creator = 'erlendaasland'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44087
    keywords = ['patch', 'easy (C)']
    message_count = 3.0
    messages = ['393310', '396189', '396201']
    nosy_count = 5.0
    nosy_names = ['berker.peksag', 'serhiy.storchaka', 'pablogsal', 'miss-islington', 'erlendaasland']
    pr_nums = ['26567', '26813', '26816']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44087'
    versions = []

    Activity

    1. erlend-aasland commented on May 9, 2021

      @erlend-aasland
      ContributorAuthor

      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.

    2. added
      type-feature
      on May 9, 2021
    3. pablogsal commented on Jun 20, 2021

      @pablogsal
      Member

      New changeset 7d0a47e by Erlend Egeberg Aasland in branch 'main':
      bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567)
      7d0a47e

    4. pablogsal commented on Jun 20, 2021

      @pablogsal
      Member

      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

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      easytype-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions