bpo-12611: 2to3 crashes when converting doctest using reduce() by aldwinaldwin · Pull Request #15249 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Lib/lib2to3/refactor.py
24 changes: 24 additions & 0 deletions Lib/lib2to3/tests/test_fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,30 @@ def test_unchanged(self):
s = "reduce()"
self.unchanged(s)

class Test_doctests(FixerTestCase):
fixer = "reduce"

def check(self, before, after, ignore_warnings=False):
before = support.reformat(before)
after = support.reformat(after)
output = self.refactor.refactor_docstring(before, self.filename)
self.assertEqual(after, output)

def test_reduce(self):
# See issue 12611
b = """\
'''
>>> reduce(lambda x, y: x + y, seq)
'''
"""
a = """\
'''
>>> from functools import reduce
>>> reduce(lambda x, y: x + y, seq)
'''
"""
self.check(b, a)

class Test_print(FixerTestCase):
fixer = "print"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2to3 converting doctest using reduce(). Patch by Aldwin Pollefeyt.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change