diff --git a/Lib/ftplib.py b/Lib/ftplib.py index 2f092d50f31782..58c209e18fb1ce 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -818,7 +818,11 @@ def parse227(resp): global _227_re if _227_re is None: import re - _227_re = re.compile(r'(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)', re.ASCII) + # The negative lookbehind keeps the search from retrying at every + # digit of a long run, which made parsing quadratic for replies + # that do not contain six comma-separated numbers (gh-162867). + _227_re = re.compile(r'(?