Import the implementation under test in external scripts

Patch applied upstream.
Get the encoding in QuotedString from the connection
Typecasters are callable
Raise DataError on malformed array strings
Fixed QuoteString when prepare() is not called
Error has a cursor, but it's picklable
Added Diagnostics object

As in psycopg, the Error takes ownership of the pgres (which is easier to do
in C than in Python...).

PG_DIAG_* fields updated to PostgreSQL 9.3, currently under development.
Expose lobject in extensions module
Fixed variable referenced before assignment raising exceptions