[Python-3000] lib2to3 refactor.py has a lot of 2.6-isms

Collin Winter collinw at gmail.com
Fri Jul 25 06:58:28 CEST 2008


On Thu, Jul 24, 2008 at 9:39 PM, Robert Brewer <fumanchu at aminus.org> wrote:
> Raymond Hettinger wrote:
>> The intended upgrade path is through 2.6.
>> If you go straight from 2.5, you don't get
>> to go through a step with the -3 warnings
>> and optional text/bytes annotations.
>>
>> IMO, it would be a mistake to create a 2.5 to 3.0 converter.
>>
>> ----- Original Message -----
>> From: "Robert Brewer" <fumanchu at aminus.org>
>> To: "Python 3000" <python-3000 at python.org>
>> Sent: Thursday, July 24, 2008 9:24 PM
>> Subject: [Python-3000] lib2to3 refactor.py has a lot of 2.6-isms
>>
>>
>> > The README at
>> >
>>
> http://svn.python.org/view/sandbox/trunk/2to3/README?rev=65003&view=aut
>> o
>> > says: "2to3 must be run (at the moment) with Python 2.x!" However,
> it
>> > doesn't even import under 2.5.2 because of print() statements,
>> > 'Exception as err', .relative imports, etc.
>> >
>> > Is this an attempt to make people upgrade to 2.6 before converting
> to
>> 3?
>> > Or is the desire to eventually run under 3.0? If neither, would
> y'all
>> > welcome a version that ran under 2.5? I'd be happy to try my hand at
>> > that.
>
> That's fine by me. But every combination of refactor.py with 2.6 and 3.0
> is also failing. Which combination is the preferred one so I can try to
> fix it?
>
> C:\Python25\Lib\site-packages>c:\python30\python
> c:\python30\Lib\lib2to3\refactor.py --help
> Traceback (most recent call last):
>  File "c:\python30\Lib\lib2to3\refactor.py", line 25, in <module>
>    from .pgen2 import driver
> ValueError: Attempted relative import in non-package
>
> C:\Python25\Lib\site-packages>c:\python26\python
> c:\python30\Lib\lib2to3\refactor.py --help
>  File "c:\python30\Lib\lib2to3\refactor.py", line 67
>    print("At least one file or directory argument required.",
> file=sys.stderr)
>                                                                   ^
> SyntaxError: invalid syntax
>
> C:\Python25\Lib\site-packages>c:\python26\python
> c:\python26\Lib\lib2to3\refactor.py --help
> Traceback (most recent call last):
>  File "c:\python26\Lib\lib2to3\refactor.py", line 25, in <module>
>    from .pgen2 import driver
> ValueError: Attempted relative import in non-package
>
> C:\Python25\Lib\site-packages>c:\python30\python
> c:\python26\Lib\lib2to3\refactor.py --help
>  File "c:\python26\Lib\lib2to3\refactor.py", line 61
>    print "Available transformations for the -f/--fix option:"
>                                                             ^
> SyntaxError: invalid syntax

Ah, this is a docs problem: the entry point is ./2to3, not
lib2to3/refactor.py. I've just committed r65224 to fix the README.

$ py26 2to3 --helpUsage: refactor.py [options] file|dir ...

Options:
  -h, --help            show this help message and exit
  -d, --doctests_only   Fix up doctests only
  -f FIX, --fix=FIX     Each FIX specifies a transformation; default all
  -l, --list-fixes      List available transformations (fixes/fix_*.py)
  -p, --print-function  Modify the grammar so that print() is a function
  -v, --verbose         More verbose logging
  -w, --write           Write back modified files
$

In the olden days, 2to3 used to run on 2.4, 2.5 and 2.6, but at some
point (PyCon 2008, I believe) the decision was taken to intentionally
drop support for 2.4 and 2.5.

Collin


More information about the Python-3000 mailing list