diff --git a/Lib/csv.py b/Lib/csv.py index dc85077f3e..f2ee0e1693 100644 --- a/Lib/csv.py +++ b/Lib/csv.py @@ -410,7 +410,7 @@ def has_header(self, sample): for col in list(columnTypes.keys()): - for thisType in [int, float, complex]: + for thisType in [complex, float, int]: try: thisType(row[col]) break diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index a98707ce3c..f5f8cd87fb 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -1238,5 +1238,14 @@ def test__all__(self): support.check__all__(self, csv, ('csv', '_csv'), extra=extra) +class TestSniffer(unittest.TestCase): + mixed = '''"time","forces" +0,0 +0.5,0.9 +''' + def test_issue43625(self): + sniffer = csv.Sniffer() + self.assertTrue(sniffer.has_header(self.mixed)) + if __name__ == '__main__': unittest.main()