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

Hallvard B Furuseth report at bugs.python.org
Mon Nov 15 15:51:07 CET 2010


Hallvard B Furuseth <h.b.furuseth at usit.uio.no> added the comment:

Martin v. Löwis writes:
> As this code is in a Python 2.x block: why does this change cause
> problems to you? You are supposed to run the 2to3 result in Python 3,
> and this conversion result will run correctly in Python 3.

As I've explained, and as the if-statement and the associated comment
expresses, that piece of code is intended to work with both Python 2
and 3.

2to3 turns it into code which would break on Python 2.  I've explained
why I'd run 2to3 on such code, and thus why it'd be convenient if I
could ask 2to3 to leave such code alone.  So I requested this feature.
I don't know exactly how I'm "supposed" to use 2to3.  If you are its
inventor, you do.  Otherwise it may also be supposed to suit other
workflows than yours.

> Ok, I can propose two different spellings of this without any
> macro processor: (...)

Both your examples fit my request perfectly.  Pieces of code which I
presume are correct for both Python 2 and 3, and 2to3 break them for
both Python versions.  With "my" feature, the code would keep working
with both.

However, it is true that there are other cases where I'd like to shut
up 2to3 but where my suggested solution would not be convenient to
use.  I am after all requesting a mere convenience feature, and aimed
for something I hoped would be a simple matter to implement.  I never
imagined that merely explaining it would grow into such a discussion.

Bobby, thanks for the sa2to3 reference.  Doesn't quite do what I
wanted, but looks useful and might also be a good starting point for
what I did ask for.  Hopefully I won't need to understand too much
2to3 code first...

----------

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


More information about the Python-bugs-list mailing list