diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index c82486532530f..058d65b9464ae 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2929,7 +2929,7 @@ def _next_iter_line(self, row_num): if self.warn_bad_lines or self.error_bad_lines: msg = str(e) - if "NULL byte" in msg: + if "NULL byte" in msg or "line contains NUL" in msg: msg = ( "NULL byte detected. This byte " "cannot be processed in Python's " diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 3d657418e43cd..6e6c31bc5b972 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -1915,10 +1915,7 @@ def test_null_byte_char(all_parsers): out = parser.read_csv(StringIO(data), names=names) tm.assert_frame_equal(out, expected) else: - if compat.PY38: - msg = "line contains NUL" - else: - msg = "NULL byte detected" + msg = "NULL byte detected" with pytest.raises(ParserError, match=msg): parser.read_csv(StringIO(data), names=names)