summaryrefslogtreecommitdiffstats
path: root/Lib/csv.py
diff options
context:
space:
mode:
authorandrei kulakov <andrei.avk@gmail.com>2021-07-30 17:10:37 (GMT)
committerGitHub <noreply@github.com>2021-07-30 17:10:37 (GMT)
commitceea579ccc51791f3e115155d6f27905bc7544a9 (patch)
tree09c3575db3b9d802ffb5afcf40c08b1717bee8f3 /Lib/csv.py
parente3f877c32d7cccb734f45310f26beeec793364ce (diff)
downloadcpython-ceea579ccc51791f3e115155d6f27905bc7544a9.zip
cpython-ceea579ccc51791f3e115155d6f27905bc7544a9.tar.gz
cpython-ceea579ccc51791f3e115155d6f27905bc7544a9.tar.bz2
bpo-43625: Enhance csv sniffer has_headers() to be more accurate (GH-26939)
Diffstat (limited to 'Lib/csv.py')
-rw-r--r--Lib/csv.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/csv.py b/Lib/csv.py
index dc85077..bb3ee26 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])