Package: python-pysqlite2
Version: 2.3.2-2
Severity: normal

pysqlite-2.3.2 accepts binary data on insertss but selects return unicode
strings. This results in unicode conversion bugs when non-unicode bytes
are stored in the database.

As sqlite3 accepts binary data in text fields, this seems to be a bug in
pysqlite. To fix it, one could i) either restrict inserts to unicode strings
or ii) change the result from unicode to binary.

However, the first would break compatibility with sqlite and that latter
would break compatibility with existing code. Thus, this should be
discussed with the authors.

Here is sample code that demonstrates this issue:

--- >8 ---
#!/usr/bin/env python
#
# Benjamin Schweizer <code at benjamin-schweizer dot de>

import sqlite3

connection = sqlite3.connect(':memory:')
cursor = connection.cursor()
cursor.execute('''CREATE TABLE test (t TEXT)''')
cursor.execute('''INSERT INTO test (t) VALUES (?)''', (chr(128),))
cursor.execute('''SELECT t FROM test''')
# Traceback (most recent call last):
# File "pysqlite_utf8.py", line 10, in <module>
#     cursor.execute('''SELECT t FROM test''')
#     sqlite3.OperationalError: Could not decode to UTF-8 column 't'
#     with text '?'

print cursor.fetchone()
connection.close()

# eof.
--- >8 ---

This sample can be downloaded from
http://benjamin-schweizer.de/files/sqlite/pysqlite-2.3.2_unicode_bug.py


Cheers


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-k7
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)

Versions of packages python-pysqlite2 depends on:
ii  libc6                  2.3.6.ds1-13etch5 GNU C Library: Shared libraries
ii  libsqlite3-0           3.3.8-1.1         SQLite 3 shared library
ii  python                 2.4.4-2           An interactive high-level object-o
ii  python-central         0.5.12            register and build utility for Pyt

python-pysqlite2 recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to