Issue 12611: 2to3 crashes when converting doctest using reduce() (original) (raw)
2to3 crashes when run on a doctest which uses reduce(). This happens with both 2.7 and 3.2's 2to3. I have the following code in a compatibility file, but even using that it fails with the same error:
try: from functools import reduce except ImportError: reduce = reduce
This is the traceback produced:
Traceback (most recent call last): File "/usr/local/bin/2to3", line 6, in sys.exit(main("lib2to3.fixes")) File "/usr/local/lib/python2.6/lib2to3/main.py", line 173, in main options.processes) File "/usr/local/lib/python2.6/lib2to3/refactor.py", line 620, in refactor items, write, doctests_only) File "/usr/local/lib/python2.6/lib2to3/refactor.py", line 275, in refactor self.refactor_file(dir_or_file, write, doctests_only) File "/usr/local/lib/python2.6/lib2to3/refactor.py", line 661, in refactor_file *args, **kwargs) File "/usr/local/lib/python2.6/lib2to3/refactor.py", line 321, in refactor_file output = self.refactor_docstring(input, filename) File "/usr/local/lib/python2.6/lib2to3/refactor.py", line 500, in refactor_docstring indent, filename)) File "/usr/local/lib/python2.6/lib2to3/refactor.py", line 530, in refactor_doctest assert clipped == [u"\n"] * (lineno-1), clipped AssertionError: [u'from functools import reduce\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n', u'\n']