@@ -13,8 +13,11 @@ from cpython cimport (PyObject, PyBytes_FromString,
1313 PyUnicode_Check, PyUnicode_AsUTF8String,
1414 PyErr_Occurred, PyErr_Fetch)
1515from cpython.ref cimport PyObject, Py_XDECREF
16- from io.common import CParserError , DtypeWarning, EmptyDataError
16+ from io.common import ParserError , DtypeWarning, EmptyDataError
1717
18+ # Import CParserError as alias of ParserError for backwards compatibility.
19+ # Ultimately, we want to remove this import. See gh-12665 and gh-14479.
20+ from io.common import CParserError
1821
1922cdef extern from " Python.h" :
2023 object PyUnicode_FromString(char * v)
@@ -719,7 +722,7 @@ cdef class TextReader:
719722 if isinstance (msg, list ):
720723 msg = " [%s ], len of %d ," % (
721724 ' ,' .join([ str (m) for m in msg ]), len (msg))
722- raise CParserError (
725+ raise ParserError (
723726 ' Passed header=%s but only %d lines in file'
724727 % (msg, self .parser.lines))
725728
@@ -812,7 +815,7 @@ cdef class TextReader:
812815 passed_count = len (header[0 ])
813816
814817 # if passed_count > field_count:
815- # raise CParserError ('Column names have %d fields, '
818+ # raise ParserError ('Column names have %d fields, '
816819 # 'data has %d fields'
817820 # % (passed_count, field_count))
818821
@@ -1004,7 +1007,7 @@ cdef class TextReader:
10041007 (num_cols >= self .parser.line_fields[i]) * num_cols
10051008
10061009 if self .table_width - self .leading_cols > num_cols:
1007- raise CParserError (
1010+ raise ParserError (
10081011 " Too many columns specified: expected %s and found %s " %
10091012 (self .table_width - self .leading_cols, num_cols))
10101013
@@ -1059,7 +1062,7 @@ cdef class TextReader:
10591062 self .use_unsigned)
10601063
10611064 if col_res is None :
1062- raise CParserError (' Unable to parse column %d ' % i)
1065+ raise ParserError (' Unable to parse column %d ' % i)
10631066
10641067 results[i] = col_res
10651068
@@ -1310,7 +1313,7 @@ def _is_file_like(obj):
13101313 if PY3:
13111314 import io
13121315 if isinstance (obj, io.TextIOWrapper):
1313- raise CParserError (' Cannot handle open unicode files (yet)' )
1316+ raise ParserError (' Cannot handle open unicode files (yet)' )
13141317
13151318 # BufferedReader is a byte reader for Python 3
13161319 file = io.BufferedReader
@@ -2015,7 +2018,7 @@ cdef raise_parser_error(object base, parser_t *parser):
20152018 else :
20162019 message += ' no error message set'
20172020
2018- raise CParserError (message)
2021+ raise ParserError (message)
20192022
20202023
20212024def _concatenate_chunks (list chunks ):
0 commit comments