From: | Federico Di Gregorio <federico(dot)digregorio(at)dndg(dot)it> |
---|---|
To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: client encoding name normalization in psycopg 2.4 |
Date: | 2011-04-08 13:14:00 |
Message-ID: | 4D9F0A18.9050205@dndg.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 08/04/11 14:59, Daniele Varrazzo wrote:
> On Fri, Apr 8, 2011 at 12:34 PM, Federico Di Gregorio
> <federico(dot)digregorio(at)dndg(dot)it> wrote:
>> > On 07/04/11 21:46, Peter Eisentraut wrote:
>> > [snip]
>>> >> Attached is a patch that implements that. Note that the PostgreSQL
>>> >> backend version of this actually lowercases the encoding names during
>>> >> normalization. I have made this patch uppercase them to keep the patch
>>> >> smaller, but you may want to consider doing the lowercasing, to keep
>>> >> things consistent.
>> >
>> > The patch seems fine to me. I'll check it in later during the we.
> I was working on the patch, but there's something not straightforward.
>
> I think assuming that psycopg2.extensions.encodings[conn.encoding]
> will always work is reasonable (also because it's the only way to
> convert the PG encoding to a Python encoding). The patch breaks this
> assumption, without which getting the Python codec name from the PG
> encoding becomes a convoluted operation.
>
> A better fix is probably to set connection.encoding to the normalized
> string, so that the lookup will always work. This means that
> connection.encoding is no more exactly what returned by SHOW
> connection_encoding but I don't think this is really important
> (furthermore the current code already converts it in uppercase).
Yep, that was my idea too. The patch already contains code to normalize
the encoding so it should be straightforward to have a normalized
conn.encoding.
federico
--
Federico Di Gregorio federico(dot)digregorio(at)dndg(dot)it
Studio Associato Di Nunzio e Di Gregorio http://dndg.it
99.99999999999999999999% still isn't 100% but sometimes suffice. -- Me
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Sienkiewicz | 2011-04-08 16:23:30 | Re: portable DBAPI auto-increment |
Previous Message | Daniele Varrazzo | 2011-04-08 12:59:35 | Re: client encoding name normalization in psycopg 2.4 |