[Python-porting] Port of psycopg2

"Martin v. Löwis" martin at v.loewis.de
Mon Dec 8 23:25:53 CET 2008


> It's more about moving to Python 2.6 syntax *only*.  eg, using 'bytes' or
> memory views etc as porting aids isn't that useful when targetting earlier
> versions. 

In the Django port, I do use (something like) bytes throughout the code,
and do so for all versions. I do

from django.utils.py3 import b

then

  b("Hallo")

which is is equivalent to b"Hallo", but works for all versions of
Python (it's implemented as .encode("ascii") in 3k)
(in addition, Django has its own SafeStr/SafeUnicode classes which
need special consideration)

I tend to ignore the suggestion of porting to 2.6 first, and also tend
to ignore the suggestion of using the -3 option. This is, of course,
because there are plenty of test cases for the software I'm porting,
so I can be reasonably certain that all aspects get covered. I then
don't need -3 to tell me what *might* break - I know for certain what
*did* break.

It would be an interesting experiment to test whether -3 still reports
anything after I completed porting - any such reports should then be
considered false positives.

Regards,
Martin


More information about the Python-porting mailing list