gjhiggins/rdflib — Issue #21: nt parser fails when file has only whitespace after multiple of bufsiz bytes
Author: gjhiggins
Created: 2011-10-19 00:56:36+00:00
State: open

Originally filed by azarot...@gmail.com on 2008-04-17T14:09:20

What steps will reproduce the problem?
1. Pick any valid N Triples file
2. Add 2048 whitespace characters
3. parse and see error

What is the expected output? What do you see instead?
Expected output is a graph.
Exception raised: EOF in line

What version of the product are you using? On what operating system?
Latest.

Please provide any additional information below.

Fix:

In rdflib/syntax/parsers/ntriples.py

Line 149, in readline() method:
while True:
m = r_line.match(self.buffer)
if m: # the more likely prospect
self.buffer = self.buffer[m.end():]
return m.group(1)
else:
buffer = self.file.read(bufsiz)
if not buffer and not self.buffer.isspace():
raise ParseError("EOF in line")
elif not buffer:
return None
self.buffer += buffer