diff options
author | andrei kulakov <andrei.avk@gmail.com> | 2021-07-30 13:10:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 19:10:37 +0200 |
commit | ceea579ccc51791f3e115155d6f27905bc7544a9 (patch) | |
tree | 09c3575db3b9d802ffb5afcf40c08b1717bee8f3 /Lib/csv.py | |
parent | e3f877c32d7cccb734f45310f26beeec793364ce (diff) | |
download | cpython-git-ceea579ccc51791f3e115155d6f27905bc7544a9.tar.gz |
bpo-43625: Enhance csv sniffer has_headers() to be more accurate (GH-26939)
Diffstat (limited to 'Lib/csv.py')
-rw-r--r-- | Lib/csv.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/csv.py b/Lib/csv.py index dc85077f3e..bb3ee269ae 100644 --- a/Lib/csv.py +++ b/Lib/csv.py @@ -409,14 +409,10 @@ class Sniffer: continue # skip rows that have irregular number of columns for col in list(columnTypes.keys()): - - for thisType in [int, float, complex]: - try: - thisType(row[col]) - break - except (ValueError, OverflowError): - pass - else: + thisType = complex + try: + thisType(row[col]) + except (ValueError, OverflowError): # fallback to length of string thisType = len(row[col]) |