New submission from Erlend E. Aasland <erlend.aasl...@innova.no>:
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 ---------- components: Extension Modules messages: 401248 nosy: erlendaasland, petr.viktorin priority: normal severity: normal status: open title: [sqlite3] cleanup and harden connection init versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45126> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com