This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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:
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 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
fix_syntax.diff bhy, 2008-09-11 16:32 A patch on 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 used Python 2.x's
print syntax, and the 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

Traceback (most recent call last):
  File "/usr/bin/2to3", line 6, in <module>
  File "/home/kid/python-site/lib2to3/", line 71, in main
    rt = refactor.RefactoringTool(fixer_names, rt_opts, explicit=explicit)
  File "/home/kid/python-site/lib2to3/", line 119, in __init__
    self.pre_order, self.post_order = self.get_fixers()
  File "/home/kid/python-site/lib2to3/", line 138, in get_fixers
    mod = __import__(fix_mod_path, {}, {}, ["*"])
  File "/home/kid/python-site/lib2to3/fixes/", line 38, in
    class FixDict(fixer_base.BaseFix):
  File "/home/kid/python-site/lib2to3/fixes/", line 76, in
    p1 = patcomp.compile_pattern(P1)
  File "/home/kid/python-site/lib2to3/", line 186, in
    return PatternCompiler().compile_pattern(pattern)
  File "/home/kid/python-site/lib2to3/", line 57, in
    root = self.driver.parse_tokens(tokens, debug=debug)
  File "/home/kid/python-site/lib2to3/pgen2/", line 45, in
    for quintuple in tokens:
  File "/home/kid/python-site/lib2to3/", line 34, in
    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 to fix this.
msg73056 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-11 21:00 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.
Date User Action Args
2022-04-11 14:56:39adminsetgithub: 48086
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