RDFLib / rdflib-leveldb

A LevelDB-backed RDFLib Store for RDFLib=>6.0
BSD 3-Clause "New" or "Revised" License
16 stars 9 forks source link

Python 3 byte/string errors #5

Closed bernhardwinkel closed 2 years ago

bernhardwinkel commented 8 years ago

Running "rdflib.Graph('LevelDB')" gave the error: ..... File "/home/****/anaconda3/lib/python3.5/site-packages/rdflib_leveldb/leveldbstore.py", line 31, in import rdflib_leveldb.picklr as picklr File "rdflib_leveldb/picklr.pyx", line 2, in init rdflib_leveldb.picklr (rdflib_leveldb/picklr.c:2037) ImportError: cannot import name GraphValue

So I went to picklr.pyx and removed all references to GraphValue, since the class is obsolete. I then reran the command, and got this long traceback:

Traceback (most recent call last): File "/home/_/anaconda3/lib/python3.5/site-packages/rdflib_leveldb/lru.py", line 29, in wrapper result = cache.pop(key) KeyError: (<rdflib_leveldb.leveldbstore.LevelDBStore object at 0x7f6032c40ef0>, rdflib.term.URIRef('file:///home/_/storage/reference-data/misc/?xml version="1.0"?'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/_/anaconda3/lib/python3.5/site-packages/rdflib_leveldb/lru.py", line 67, in wrapper result = cache[key] KeyError: (<rdflib_leveldb.leveldbstore.LevelDBStore object at 0x7f6032c40ef0>, rdflib.term.URIRef('file:///home/_/storage/reference-data/misc/?xml version="1.0"?'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "rdf.py", line 11, in efo.parse(ontodir + 'efo.rdf', format='n3') File "/home/_/anaconda3/lib/python3.5/site-packages/rdflib/graph.py", line 1041, in parse parser.parse(source, self, _args) File "/home/**/anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 1899, in parse TurtleParser.parse(self, source, conj_graph, encoding, turtle=False) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 1870, in parse p.loadStream(source.getByteStream()) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 434, in loadStream return self.loadBuf(stream.read()) # Not ideal File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 440, in loadBuf self.feed(buf) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 466, in feed i = self.directiveOrStatement(s, j) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 487, in directiveOrStatement j = self.statement(argstr, i) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 725, in statement j = self.property_list(argstr, i, r[0]) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 1093, in property_list self.makeStatement((self._context, sym, subj, obj)) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 716, in makeStatement self._store.makeStatement(quadruple, why=self._reason2) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 1764, in makeStatement self.graph.add((s, p, o)) File "/home//anaconda3/lib/python3.5/site-packages/rdflib/graph.py", line 1324, in add self.store.add((s, p, o), context=c, quoted=False) File "/home//anaconda3/lib/python3.5/site-packages/rdflib_leveldb/leveldbstore.py", line 203, in add s = _to_string(subject) File "/home//anaconda3/lib/python3.5/site-packages/rdflib_leveldb/lru.py", line 32, in wrapper result = user_function(_args, *_kwds) File "/home/*/anaconda3/lib/python3.5/site-packages/rdflib_leveldb/lru.py", line 70, in wrapper result = user_function(_args, _kwds) File "/home/**/anaconda3/lib/python3.5/site-packages/rdflib_leveldb/leveldbstore.py", line 399, in _to_string self.__k2i.Put(k, i) TypeError: a bytes-like object is required, not 'str'

ghost commented 2 years ago

Fixed in revamp to Python 3 / RDFLib 6