logo       

Python crash with non-UTF8 and invalid timestamp combination: msg#00067

python.db.pysqlite.user

Subject: Python crash with non-UTF8 and invalid timestamp combination

I hope I've narrowed this down as as far as it can go. I'm experiencing a
situation where pysqlite appears to be crashing python.exe under Windows.

pysqlite: 2.2.1
sqlite: 3.3.5
python: 2.4.3 (from python.org)
Windows: XP Professional SP2

It appears to occur only when a text field contains invalid UTF-8 data and
there is a timestamp field with auto-conversion turned on. The example
below consistently reproduces a crash -- ie a Windows dialog box
complaining that "python.exe has encountered a problem and needs to close.
We are sorry for the inconvenience."

Specific points to note:

1) The detect_types clause must be present for failure to occur
2) Both columns must be present for failure to occur
3) The TEXT field must be invalid UTF-8 (afaict).
4) It doesn't seem to matter what's in the timestamp field.
5) The row must be iterated over -- ie the list (row) is essential

This isn't a showstopper for me; I can just correct the invalid UTF-8,
which I suspect is some kind of Windows special quotes in text supplied by
another user. But it's so unusual to see something in Python actually
crash enough to take the interpreter down!

TJG

<code>
from pysqlite2 import dbapi2 as sqlite

print sqlite.version, sqlite.sqlite_version

db = sqlite.connect (":memory:", detect_types=sqlite.PARSE_DECLTYPES)
db.execute ("CREATE TABLE t (a TEXT, d timestamp)")
db.execute ("INSERT INTO t (a, d) VALUES (?, ?)", ["\xf4", ""])

for row in db.execute ("SELECT * FROM t"):
print row, list (row)

</code>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise