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 Oren Milman
Recipients Oren Milman
Date 2017-10-10.14:31:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507645879.63.0.213398074469.issue31746@psf.upfronthosting.co.za>
In-reply-to
Content
The following code causes a crash:
import sqlite3
connection = sqlite3.Connection.__new__(sqlite3.Connection)
connection.isolation_level

This is because pysqlite_connection_get_isolation_level() doesn't check whether
the Connection object is initialized.
pysqlite_connection_close() also doesn't check that, so we would get a crash
also if we replaced `connection.isolation_level` with `connection.close()`.

pysqlite_connection_set_isolation_level() doesn't crash in case of an
uninitialized Connection object, but it also doesn't raise an error, and IMHO
it should.


The following code causes a crash, too:
import sqlite3
try:
    connection = sqlite3.Connection.__new__(sqlite3.Connection)
    connection.__init__('', isolation_level='invalid isolation level')
except ValueError:
    pass

connection.cursor()

This is because `self->initialized` is set to 1 in the beginning of
pysqlite_connection_init(), so after it fails, we are left with a partially
initialized Connection object whose `self->initialized` is 1. Thus,
pysqlite_connection_cursor() thinks that the Connection object is initialized.
Eventually pysqlite_connection_register_cursor() is called, and it crashes
while trying to append to `connection->cursors`, which is NULL.
History
Date User Action Args
2017-10-10 14:31:19Oren Milmansetrecipients: + Oren Milman
2017-10-10 14:31:19Oren Milmansetmessageid: <1507645879.63.0.213398074469.issue31746@psf.upfronthosting.co.za>
2017-10-10 14:31:19Oren Milmanlinkissue31746 messages
2017-10-10 14:31:19Oren Milmancreate