Py 3: How to switch application to Unicode strings?

Mark Tolonen metolone+gmane at
Wed Jan 20 04:34:12 CET 2010

"Stephen Hansen" <apt.shansen at> wrote in message 
news:7a9c25c21001191156j46a7fdadt58b728477b85e651 at
> On Tue, Jan 19, 2010 at 7:50 AM, Gnarlodious <gnarlodious at> 
> wrote:
>> I am using Python 3, getting an error from SQLite:
>> sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless
>> you use a text_factory that can interpret 8-bit bytestrings (like
>> text_factory = str). It is highly recommended that you instead just
>> switch your application to Unicode strings.
>> So... how do I switch to Unicode? I thought I was doing it when I put
> # coding:utf-8
>> at the start of my script.
> All that does is mean that the script itself is encoded as utf8.

Actually it means that the user has declared that the source file is encoded 
in utf-8.  A common source of errors is that the source file is *not* 
encoded in utf-8.  Make sure to save the source file in the encoding 


More information about the Python-list mailing list