﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20984	"sqlite3 adaptors tries to ""decode"" str value when running on Python 3"	lvella@…	nobody	"I ran into this error when I tried to execute Django on the experimental Pypy3 2.1 (yes, experimental over experimental), and luckly, due to a [https://bugs.pypy.org/issue1591 bug] in Pypy support of Python 3, I think I found one on Django. CPython swallows exceptions raised inside sqlite3 adapters, Pypy didn't, thus I found that Django execute these lines, even on Python 3:

{{{
if Database.version_info >= (2, 4, 1):
    # Starting in 2.4.1, the str type is not accepted anymore, therefore,
    # we convert all str objects to Unicode
    # As registering a adapter for a primitive type causes a small
    # slow-down, this adapter is only registered for sqlite3 versions
    # needing it (Python 2.6 and up).
    Database.register_adapter(str, lambda s: s.decode('utf-8'))
    Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
}}}

where the str adapter led to a fatal exception on experimental Pypy. But since unicode is str and str is bytes on Python 3 (and bytes is an alias to str on Python 2.6), the relevant line should be:
{{{
    Database.register_adapter(bytes, lambda s: s.decode('utf-8'))
}}}

Or event be suppressed if on py3k... why would one be passing bytes to the database where it expects a string?
The same line is still there on master..."	Bug	closed	Python 3	1.5	Normal	fixed			Accepted	0	0	0	0	1	0
