AttributeError: module 'posixpath' has no attribute 'sep'
When running Graph.pars with format="json-ld" in python 3.10.4 I get. the following error.
AttributeError: module 'posixpath' has no attribute 'sep'
The problem seems to stem from the following line due to the fact that sep is no longer a part of posixpath.
Replacing
from posixpath import normpath, sep
with
from posixpath import normpath
from os import sep
should solve the problem.
How to reproduce: Run the following code in python 3.10.4 or higher:
from rdflib import Graph
g = Graph()
g.parse(data='{"@type": "Actor", "@id": "http://test.io/olcaId/0044417a-cd8e-447c-8205-d158af171f81", "@context": "http://test.github.io/olca-schema/context.jsonld"}', format="json-ld")
Replacing
from posixpath import normpath, sepwith
from posixpath import normpath from os import sepshould solve the problem.
Thanks for the report, however this will use the wrong separator on windows I think as os.sep is OS dependent.
Will look at it when we can though and PRs are always welcome. We should also figure out why this was not picked up by our continuous integration which does run the test suite on 3.10
Related:
- https://github.com/stub42/pytz/issues/72
- https://github.com/pallets/jinja/issues/1697
Any updates on this? @aucampia
Just made a PR. @aucampia
The problem seems to stem from the following line due to the fact that
sepis no longer a part ofposixpath.
Is it not? I really am not sure why you get this error when we don't get it on our CI systems. It is also still documented in python 3.11
$ pydoc3.11 posixpath | sed -n '/^DATA/,/^$/p'
DATA
__all__ = ['normcase', 'isabs', 'join', 'splitdrive', 'split', 'splite...
altsep = None
curdir = '.'
defpath = '/bin:/usr/bin'
devnull = '/dev/null'
extsep = '.'
pardir = '..'
pathsep = ':'
sep = '/'
supports_unicode_filenames = False
$ pydoc3.10 posixpath | sed -n '/^DATA/,/^$/p'
DATA
__all__ = ['normcase', 'isabs', 'join', 'splitdrive', 'split', 'splite...
altsep = None
curdir = '.'
defpath = '/bin:/usr/bin'
devnull = '/dev/null'
extsep = '.'
pardir = '..'
pathsep = ':'
sep = '/'
supports_unicode_filenames = False
As indicated in the now closed PR https://github.com/RDFLib/rdflib/pull/2156, it is not clear how to reproduce this. We run tests on all python versions and platforms and cant reproduce this issue.
I'm going to close this, if you can give us a way to reproduce this cleanly we can change it, but the code is using documented parts of the python API, so it does not seem like a problem with RDFLib.