From 0c7738e66085c3409a2fcd154a9ff5b363fc4d93 Mon Sep 17 00:00:00 2001 From: Andrew Hawryluk Date: Mon, 15 Mar 2021 21:21:22 -0600 Subject: [PATCH 1/3] BUG: add test for closed GH14782 --- pandas/tests/io/parser/common/test_common_basic.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index b4ac419fba30c..297cbbe66cb6b 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -753,3 +753,12 @@ def test_encoding_surrogatepass(all_parsers): tm.assert_frame_equal(df, expected) with pytest.raises(UnicodeDecodeError, match="'utf-8' codec can't decode byte"): parser.read_csv(path) + + +def test_malformed_second_line(all_parsers): + # see GH14782 + parser = all_parsers + data = "\na\nb\n" + result = parser.read_csv(StringIO(data), skip_blank_lines=False, header=1) + expected = DataFrame({"a": ["b"]}) + tm.assert_frame_equal(result, expected) From 65109357cd5a7e22a6e0b57ee88a5a43df54dafb Mon Sep 17 00:00:00 2001 From: Andrew Hawryluk Date: Mon, 15 Mar 2021 21:38:16 -0600 Subject: [PATCH 2/3] Add whatsnew entry --- doc/source/whatsnew/v1.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index fad734a0e39ad..c4d4a08577354 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -539,6 +539,7 @@ I/O - Bug in :func:`read_hdf` returning unexpected records when filtering on categorical string columns using ``where`` parameter (:issue:`39189`) - Bug in :func:`read_sas` raising ``ValueError`` when ``datetimes`` were null (:issue:`39725`) - Bug in :func:`read_excel` dropping empty values from single-column spreadsheets (:issue:`39808`) +- Bug in :func:`read_csv` segmentation fault on malformed input (:issue:`14782`) Period ^^^^^^ From 5e2a50dc9c719f718e002f16aaa2b9033db60efd Mon Sep 17 00:00:00 2001 From: Andrew Hawryluk Date: Tue, 16 Mar 2021 10:58:05 -0600 Subject: [PATCH 3/3] Revert "Add whatsnew entry" This reverts commit 65109357cd5a7e22a6e0b57ee88a5a43df54dafb. --- doc/source/whatsnew/v1.3.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index c4d4a08577354..fad734a0e39ad 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -539,7 +539,6 @@ I/O - Bug in :func:`read_hdf` returning unexpected records when filtering on categorical string columns using ``where`` parameter (:issue:`39189`) - Bug in :func:`read_sas` raising ``ValueError`` when ``datetimes`` were null (:issue:`39725`) - Bug in :func:`read_excel` dropping empty values from single-column spreadsheets (:issue:`39808`) -- Bug in :func:`read_csv` segmentation fault on malformed input (:issue:`14782`) Period ^^^^^^