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.

classification
Title: AssertionError Tree is insane with *args and reduce
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, jaraco
Priority: normal Keywords:

Created on 2009-11-02 17:13 by jaraco, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg94835 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-11-02 17:13
Create a file with a single line of code:

def x(arg): return reduce(sum, [])

On Python 3.1.1 (I used Windows 64-bit), run 2to3 on it returns the
following error:

PS C:\Users\jaraco\projects\jaraco.util\jaraco\util>
C:\python\Tools\Scripts\2to3.py .\functools.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
Traceback (most recent call last):
  File "C:\python\Tools\Scripts\2to3.py", line 6, in <module>
    sys.exit(main("lib2to3.fixes"))
  File "C:\Python\lib\lib2to3\main.py", line 159, in main
    options.processes)
  File "C:\Python\lib\lib2to3\refactor.py", line 616, in refactor
    items, write, doctests_only)
  File "C:\Python\lib\lib2to3\refactor.py", line 276, in refactor
    self.refactor_file(dir_or_file, write, doctests_only)
  File "C:\Python\lib\lib2to3\refactor.py", line 656, in refactor_file
    *args, **kwargs)
  File "C:\Python\lib\lib2to3\refactor.py", line 328, in refactor_file
    tree = self.refactor_string(input, filename)
  File "C:\Python\lib\lib2to3\refactor.py", line 358, in refactor_string
    self.refactor_tree(tree, name)
  File "C:\Python\lib\lib2to3\refactor.py", line 392, in refactor_tree
    self.traverse_by(self.post_order_heads, tree.post_order())
  File "C:\Python\lib\lib2to3\refactor.py", line 416, in traverse_by
    new = fixer.transform(node, results)
  File "C:\Python\lib\lib2to3\fixes\fix_reduce.py", line 33, in transform
    touch_import('functools', 'reduce', node)
  File "C:\Python\lib\lib2to3\fixer_util.py", line 289, in touch_import
    root = find_root(node)
  File "C:\Python\lib\lib2to3\fixer_util.py", line 265, in find_root
    assert node.parent, "Tree is insane! root found before "\
AssertionError: Tree is insane! root found before file_input node was found.

2to3 on Python 2.6.4 does not exhibit the same error.

Remove 'arg' or the call to reduce and the problem is not exhibited.
msg94837 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-11-02 18:06
Fixed in r76061.
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51502
2009-11-02 18:06:32benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg94837
2009-11-02 17:22:09pitrousetpriority: normal
assignee: benjamin.peterson

nosy: + benjamin.peterson
2009-11-02 17:13:46jaracocreate