We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe5ffd3 commit 14a73a5Copy full SHA for 14a73a5
Lib/ast.py
@@ -307,12 +307,16 @@ def get_docstring(node, clean=True):
307
308
309
_line_pattern = re.compile(r"(.*?(?:\r\n|\n|\r|$))")
310
-def _splitlines_no_ff(source, maxlines=-1):
+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
+ """
315
lines = []
316
for lineno, match in enumerate(_line_pattern.finditer(source), 1):
- if maxlines > 0 and lineno > maxlines:
317
+ if maxlines is not None and lineno > maxlines:
318
break
- lines.append(match[0].replace("\r\n", "\n"))
319
+ lines.append(match[0])
320
return lines
321
322
0 commit comments