It doesn't work for me either. I have installed the psycopg 2.5.1 (the latest), and I always get None if the authentication fails or the server is not working in the given IP. I don't know why.

2013/9/15 Oleg Broytman <>
On Fri, Sep 13, 2013 at 11:40:09AM -0300, Francisco Chiotta <> wrote:
> It would be great.  Sure, I can test the results.

   The patch is attached. The code and error string are available:

except OperationalError, e:
    print e.args[0].code
    print e.args[0].error

   Doesn't work for me, though -- pgcode/pgerror are always None.
Perhaps I'm using old version of psycopg2 -- 2.4.5.

     Oleg Broytman    
           Programmers don't die, they just GOSUB without RETURN.