Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
csv.Sniffer regular expression has significant backtracing #109638
Copy link
Copy link
Open
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesperformancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesperformancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
StatusShow more project fields
Done
Bug report
Bug description:
You can pass strings to
csv.Snifferthat can generate significant Regex backtracing and processing time. For exampleSome example runs
I've checked against different versions of Python and they all return similar results.
This issue lies in this Regex for finding double quoted format
cpython/Lib/csv.py
Line 274 in b303d3a
I've done some testing and a zero length lookahead assertion (or atomic group) you can get a significant performance improvement
CPython versions tested on:
3.8, 3.9, 3.10, 3.11
Operating systems tested on:
Linux
Linked PRs