bpo-30157: Fix csv.Sniffer.sniff() regex pattern. (GH-5601) (GH-5602)

Co-authored-by: Jake Davis <jcdavis@awedge.net>
(cherry picked from commit 2411292ba8)
This commit is contained in:
Miss Islington (bot) 2018-02-09 14:00:48 -08:00 committed by Serhiy Storchaka
parent 7df80492fc
commit 2ef69a1d45
4 changed files with 14 additions and 1 deletions

View file

@ -217,7 +217,7 @@ class Sniffer:
matches = []
for restr in (r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?P=delim)', # ,".*?",
r'(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?P<delim>[^\w\n"\'])(?P<space> ?)', # ".*?",
r'(?P<delim>>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?:$|\n)', # ,".*?"
r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?:$|\n)', # ,".*?"
r'(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?:$|\n)'): # ".*?" (no delim, no space)
regexp = re.compile(restr, re.DOTALL | re.MULTILINE)
matches = regexp.findall(data)