Skip to content

Commit 14a73a5

Browse files
Suggestions from the review
* Docstring * Check explicitly for maxline * \n\r preserve
1 parent fe5ffd3 commit 14a73a5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/ast.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,16 @@ def get_docstring(node, clean=True):
307307

308308

309309
_line_pattern = re.compile(r"(.*?(?:\r\n|\n|\r|$))")
310-
def _splitlines_no_ff(source, maxlines=-1):
310+
def _splitlines_no_ff(source, maxlines=None):
311+
"""Split a string into lines ignoring form feed and other chars.
312+
313+
This mimics how the Python parser splits source code.
314+
"""
311315
lines = []
312316
for lineno, match in enumerate(_line_pattern.finditer(source), 1):
313-
if maxlines > 0 and lineno > maxlines:
317+
if maxlines is not None and lineno > maxlines:
314318
break
315-
lines.append(match[0].replace("\r\n", "\n"))
319+
lines.append(match[0])
316320
return lines
317321

318322

0 commit comments

Comments
 (0)