Skip to content
10 changes: 8 additions & 2 deletions pandas/parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ cdef class TextReader:
cdef:
size_t rows_read = 0
chunks = []
int status

if rows is None:
while True:
Expand All @@ -747,7 +748,9 @@ cdef class TextReader:
else:
chunks.append(chunk)

parser_trim_buffers(self.parser)
status = parser_trim_buffers(self.parser)
if status < 0:
raise_parser_error('Error trimming data', self.parser)

if len(chunks) == 0:
raise StopIteration
Expand Down Expand Up @@ -812,7 +815,10 @@ cdef class TextReader:
# trim
parser_consume_rows(self.parser, rows_read)
if trim:
parser_trim_buffers(self.parser)
status = parser_trim_buffers(self.parser)

if status < 0:
raise_parser_error('Error trimming data', self.parser)
self.parser_start -= rows_read

self._end_clock('Parser memory cleanup')
Expand Down
Loading