RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

Parsing of long lists causes python recursion problems #804

Closed hsolbrig closed 6 years ago

hsolbrig commented 6 years ago

newList in notation3.py uses recursion to load lists. Sufficiently long lists cause the interpreter to raise RecursionError: maximum recursion depth exceeded while getting the str of an object. In the example below, the list has well over 1000 entries:

from rdflib import Graph
g = Graph()
g.load('https://raw.githubusercontent.com/shexSpec/shexTest/master/validation/manifest.ttl', format='turtle')

Output:

      ...
  File "lib/python3.6/site-packages/rdflib/plugins/parsers/notation3.py", line 1743, in newList
    self.makeStatement((f, rest, a, self.newList(n[1:], f)))
     ...
RecursionError: maximum recursion depth exceeded while getting the str of an object
gromgull commented 6 years ago

Fixed in https://github.com/RDFLib/rdflib/pull/805