Skip site navigation (1) Skip section navigation (2)

Re: client encoding name normalization in psycopg 2.4

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: (view raw, whole thread or download thread mbox)
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


Federico Di Gregorio                         federico(dot)digregorio(at)dndg(dot)it
Studio Associato Di Nunzio e Di Gregorio        
  99.99999999999999999999% still isn't 100% but sometimes suffice. -- Me

In response to

psycopg by date

Next:From: Mark SienkiewiczDate: 2011-04-08 16:23:30
Subject: Re: portable DBAPI auto-increment
Previous:From: Daniele VarrazzoDate: 2011-04-08 12:59:35
Subject: Re: client encoding name normalization in psycopg 2.4

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group