Skip to content

Commit a9913ac

Browse files
Remove the unreachable \r alternatives in the sniffing regexes
sniff() now replaces \r\n and \r with \n before these regular expressions are used. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d8f003d commit a9913ac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/csv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ def _guess_quote_and_delimiter(self, data, delimiters):
293293
matches = []
294294
for restr in (r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\'])%s(?P=quote)(?P=delim)', # ,"...",
295295
r'(?:^|\n)(?P<quote>["\'])%s(?P=quote)(?P<delim>[^\w\n"\'])(?P<space> ?)', # "...",
296-
r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\'])%s(?P=quote)(?:$|\r|\n)', # ,"..."
297-
r'(?:^|\n)(?P<quote>["\'])%s(?P=quote)(?:$|\r|\n)'): # "..." (no delim, no space)
296+
r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\'])%s(?P=quote)(?:$|\n)', # ,"..."
297+
r'(?:^|\n)(?P<quote>["\'])%s(?P=quote)(?:$|\n)'): # "..." (no delim, no space)
298298
regexp = re.compile(restr % body, re.DOTALL | re.MULTILINE)
299299
matches = regexp.findall(data)
300300
if matches:

0 commit comments

Comments
 (0)