classification
Title: 2to3 broken due to mixed 2.5 and 3.0 syntax
Type: crash Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, bhy, collinwinter
Priority: high Keywords: patch

Created on 2008-09-11 16:11 by bhy, last changed 2008-09-11 21:05 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
fix_syntax.diff bhy, 2008-09-11 16:32 A patch on main.py to fix this
Messages (4)
msg73037 - (view) Author: Haoyu Bai (bhy) Date: 2008-09-11 16:11
In the py3k SVN head(r66389) of lib2to3, the main.py used Python 2.x's
print syntax, and the refactor.py used Python 3.0's exception syntax. So
the 2to3 finally broken on both Python 2.5 and 3.0.

Well, it able to run with Python 2.6, but also have a lot of errors like
this:

Traceback (most recent call last):
  File "/usr/bin/2to3", line 6, in <module>
    sys.exit(main("lib2to3.fixes"))
  File "/home/kid/python-site/lib2to3/main.py", line 71, in main
    rt = refactor.RefactoringTool(fixer_names, rt_opts, explicit=explicit)
  File "/home/kid/python-site/lib2to3/refactor.py", line 119, in __init__
    self.pre_order, self.post_order = self.get_fixers()
  File "/home/kid/python-site/lib2to3/refactor.py", line 138, in get_fixers
    mod = __import__(fix_mod_path, {}, {}, ["*"])
  File "/home/kid/python-site/lib2to3/fixes/fix_dict.py", line 38, in
<module>
    class FixDict(fixer_base.BaseFix):
  File "/home/kid/python-site/lib2to3/fixes/fix_dict.py", line 76, in
FixDict
    p1 = patcomp.compile_pattern(P1)
  File "/home/kid/python-site/lib2to3/patcomp.py", line 186, in
compile_pattern
    return PatternCompiler().compile_pattern(pattern)
  File "/home/kid/python-site/lib2to3/patcomp.py", line 57, in
compile_pattern
    root = self.driver.parse_tokens(tokens, debug=debug)
  File "/home/kid/python-site/lib2to3/pgen2/driver.py", line 45, in
parse_tokens
    for quintuple in tokens:
  File "/home/kid/python-site/lib2to3/patcomp.py", line 34, in
tokenize_wrapper
    tokens = tokenize.generate_tokens(driver.generate_lines(input).__next__)
AttributeError: 'generator' object has no attribute '__next__'
msg73042 - (view) Author: Haoyu Bai (bhy) Date: 2008-09-11 16:32
A patch on main.py to fix this.
msg73056 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-11 21:00
main.py is really not a public interface, but it should be fixed.
msg73059 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-11 21:05
Fixed in r66392.
History
Date User Action Args
2008-09-11 21:05:49benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg73059
2008-09-11 21:00:30benjamin.petersonsetpriority: high
assignee: collinwinter -> benjamin.peterson
messages: + msg73056
nosy: + benjamin.peterson
2008-09-11 16:32:36bhysetfiles: + fix_syntax.diff
keywords: + patch
messages: + msg73042
2008-09-11 16:11:07bhycreate