A text field in PostgreSQL is mixing unicode and str types

53 views
Skip to first unread message

Chris

unread,
Apr 30, 2015, 3:18:13 PM4/30/15
to web...@googlegroups.com
I'm using web2py with PostgreSQL and it's working pretty well, however, there's a weird problem. When I load a row with a text column in it, that column isn't one consistent type. It appears as <type 'unicode'> when it includes extended characters and <type 'str'> when it doesn't. I end up having to look up the type and call decode on just the strs to make sure they all have a consistent type and avoid the dreaded UnicodeDecodeError.

This is causing a bug on my setup which is Linux:
2.9.12-stable+timestamp.2015.01.17.06.11.03
(Running on Rocket 1.2.6, Python 2.7.0)

Will this/has this been patched? Is this a bug with my version of Python?

Niphlod

unread,
May 3, 2015, 8:15:19 AM5/3/15
to web...@googlegroups.com
can you post an example app to reproduce the issue ?

Chris

unread,
May 4, 2015, 1:48:16 PM5/4/15
to web...@googlegroups.com
Just spent some time reviewing this - looks OK now, I think I must have screwed up somewhere.

All db text fields in web2py are supposed to be bytestrings of <type 'str'>, right?
Reply all
Reply to author
Forward
0 new messages