RDFLib / rdflib-jsonld

JSON-LD parser and serializer plugins for RDFLib
Other
280 stars 71 forks source link

Calling rdflib.tools.rdfpipe results in AttributeError: 'str' object has no attribute 'decode' #91

Open Fak3 opened 4 years ago

Fak3 commented 4 years ago

Hi. I tried to convert from json-ld to turtle with rdflib.tools.rdfpipe and got an error:

> python -m rdflib.tools.rdfpipe -o turtle -i json-ld - <<"EOF"
  {
    "@id": "a",
    "b": [
      {
        "@id": "c"
      }
    ]
  }
EOF

Got an error with traceback:

RDFLib Version: 5.0.0
Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib/tools/rdfpipe.py", line 188, in <module>
    main()
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib/tools/rdfpipe.py", line 183, in main
    parse_and_serialize(args, opts.input_format, opts.guess,
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib/tools/rdfpipe.py", line 51, in parse_and_serialize
    graph.parse(fpath, format=use_format, **kws)
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib/graph.py", line 1549, in parse
    context.parse(source, publicID=publicID, format=format, **args)
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib/graph.py", line 1078, in parse
    parser.parse(source, self, **args)
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib_jsonld/parser.py", line 83, in parse
    data = source_to_json(source)
  File "/home/u1/.virtualenvs/nnn/lib/python3.8/site-packages/rdflib_jsonld/util.py", line 28, in source_to_json
    return json.load(StringIO(stream.read().decode('utf-8')))
AttributeError: 'str' object has no attribute 'decode'

rdflib==5.0.0 rdflib-jsonld==0.5.0

Fak3 commented 3 years ago

Maybe related: https://github.com/RDFLib/rdflib/issues/1144