File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,12 @@ def _validate_header_arg(header) -> None:
125
125
"the row(s) making up the column names"
126
126
)
127
127
128
+ # In version 0.24, this would have worked.
129
+ if header == - 1 :
130
+ raise ValueError (
131
+ "Passing -1 to header is invalid. For no header, use header=None instead"
132
+ )
133
+
128
134
129
135
def _stringify_path (
130
136
filepath_or_buffer : FilePathOrBuffer [AnyStr ]
Original file line number Diff line number Diff line change @@ -24,6 +24,20 @@ def test_read_with_bad_header(all_parsers):
24
24
parser .read_csv (s , header = [10 ])
25
25
26
26
27
+ def test_negative_header (all_parsers ):
28
+ parser = all_parsers
29
+ data = """1,2,3,4,5
30
+ 6,7,8,9,10
31
+ 11,12,13,14,15
32
+ """
33
+ with pytest .raises (
34
+ ValueError ,
35
+ match = "Passing -1 to header is invalid. "
36
+ "For no header, use header=None instead" ,
37
+ ):
38
+ parser .read_csv (StringIO (data ), header = - 1 )
39
+
40
+
27
41
@pytest .mark .parametrize ("header" , [True , False ])
28
42
def test_bool_header_arg (all_parsers , header ):
29
43
# see gh-6114
You can’t perform that action at this time.
0 commit comments