This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author erlendaasland
Recipients erlendaasland, petr.viktorin
Date 2021-09-07.11:46:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631015162.08.0.638095834379.issue45126@roundup.psfhosted.org>
In-reply-to
Content
Quoting Petr Viktorin in PR 27940, https://github.com/python/cpython/pull/27940#discussion_r703424148:

- db is not set to NULL if init fails.
- This segfaults for me:

  import sqlite3

  conn = sqlite3.connect(':memory:')
  conn.execute('CREATE TABLE foo (bar)')

  try:
      conn.__init__('/bad-file/')
  except sqlite3.OperationalError:
      pass

  conn.execute('INSERT INTO foo (bar) VALUES (1), (2), (3), (4)')


Other issues:
- reinitialisation is not handled gracefully
- __init__ is messy; members are initialised here and there


Suggested to reorder connection __init__ in logical groups to more easily handle errors:
  1. handle reinit
  2. open and configure database
  3. create statement LRU cache and weak ref cursor list
  4. initialise members in the order they're defined in connection.h
  5. set isolation level, since it's a weird case anyway
History
Date User Action Args
2021-09-07 11:46:02erlendaaslandsetrecipients: + erlendaasland, petr.viktorin
2021-09-07 11:46:02erlendaaslandsetmessageid: <1631015162.08.0.638095834379.issue45126@roundup.psfhosted.org>
2021-09-07 11:46:02erlendaaslandlinkissue45126 messages
2021-09-07 11:46:01erlendaaslandcreate