[Python-porting] Details about the psycopg porting
Antoine Pitrou
solipsis at pitrou.net
Mon Jan 24 16:20:48 CET 2011
More information about the Python-porting mailing list
Mon Jan 24 16:20:48 CET 2011
- Previous message: [Python-porting] Details about the psycopg porting
- Next message: [Python-porting] Details about the psycopg porting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello, > I've written to the Psycopg mailing list about the details in the > psycopg2 porting to Python 3. You can also read everything here: > <http://initd.org/psycopg/articles/2011/01/24/psycopg2-porting-python-3-report/>. > > There is a couple of points still open, so if you want to take a look > at them I'd be happy to receive comments before releasing the code. >From your article: > the data (bytes) from the libpq are passed to file.write() using > PyObject_CallFunction(func, "s#", buffer, len)” You shouldn't use "s#" as it will implicitly decode the buffer to unicode. Instead, use "y#" to write bytes. > Is there an interface in Python 3 to know if a file is binary or text? `isinstance(myfile, io.TextIOBase)` should do the trick. Or the corresponding C call, using PyObject_IsInstance(). > In binary mode the file always returns bytes (str in py2, unicode in py3) I suppose you mean "str in py2, bytes in py3". > bytea fields are returned as MemoryView, from which is easy to get bytes Is this because it is easier for you to return a memoryview? Otherwise it would make more sense to return a bytes object. Regards Antoine.
- Previous message: [Python-porting] Details about the psycopg porting
- Next message: [Python-porting] Details about the psycopg porting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-porting mailing list