[issue10070] 2to3 wishes for already-2to3'ed files

Bobby Impollonia report at bugs.python.org
Sat Nov 13 02:28:54 CET 2010


Bobby Impollonia <bobbyi at gmail.com> added the comment:

Consider here:
http://www.sqlalchemy.org/trac/browser/lib/sqlalchemy/engine/base.py?rev=6884:b181f1e53603#L1329
the py3k code uses the "raise ... from" syntax which isn't legal in Python 2. Using either  "Approach A" or "Approach B" would prevent the program from working in py2k due to syntax errors.

I agree that the markup hrufu proposed didn't solve that problem either. SQLA's trick of having the py3k code commented out is the critical part that they add.

Additionally, the runtime cost prevents Approach A from being general solution for libraries like SQLA who have put a lot of work into reducing the number of function calls and checks in their critical paths.

Approach B isn't a general solution because it requires you to replace entire functions at a time. If you have a 25 line function where only 1 line needs to be changed for py3k, you either end up with 24 duplicated lines of code, or you have to factor that single line out into its own function, confusing the flow of the code and incurring runtime cost.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10070>
_______________________________________


More information about the Python-bugs-list mailing list