Unicode errors with PostgreSQL and RawStr fields
Bug #1236297 reported by
Aurélien Bompard
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Mailman |
Invalid
|
High
|
Barry Warsaw |
Bug Description
When using PostgreSQL as a database, it's impossible to set the moderator_password field of a mailing list, which is of type RawStr.
To be precise, it's possible to set it, but getting it back from the database after a commit will cause a TypeError with the message:
"Expected str, found <type 'unicode'>" as if PostgreSQL always returned unicode on TEXT fields and Storm did not convert them to bytestrings. I get no errors on an SQLite database.
I don't know if the problem comes from Mailman or Storm. I have written a python script to reproduce it, see the attached file. There are comments, it should be easily readable.
Related branches
lp:~nkarageuzian/mailman/pg_update
Rejected
for merging
into
lp:mailman
- Barry Warsaw: Pending requested
-
Diff: 129 lines (+120/-0)2 files modifiedsrc/mailman/database/schema/mm_20131007000000.py (+45/-0)
src/mailman/database/schema/mm_20131203000000.py (+75/-0)
Changed in mailman: | |
milestone: | none → 3.0.0b4 |
assignee: | nobody → Barry Warsaw (barry) |
importance: | Undecided → High |
status: | New → In Progress |
Changed in mailman: | |
milestone: | 3.0.0b4 → 3.0.0b5 |
To post a comment you must log in.
I found why! In "mailman/ src/mailman/ database/ schema/ postgres. sql", the moderator_password field is of type "TEXT" instead of being "BYTEA". As a result, the psycopg2 driver converts it to an unicode string. /storm. canonical. com/Manual# Table_of_ properties_ vs._python_ vs._database_ types
This is coherent with the Storm manual which states that RawStr types should be set as BYTEA types in PostgreSQL:
https:/
I believe a schema migration script will be needed.