rdflib icon indicating copy to clipboard operation
rdflib copied to clipboard

AttributeError: module 'posixpath' has no attribute 'sep'

Open zero0nee opened this issue 3 years ago • 2 comments

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")

zero0nee avatar Aug 25 '22 15:08 zero0nee

Replacing

from posixpath import normpath, sep

with

from posixpath import normpath 
from os import sep

should 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

aucampia avatar Aug 25 '22 16:08 aucampia

Related:

  • https://github.com/stub42/pytz/issues/72
  • https://github.com/pallets/jinja/issues/1697

aucampia avatar Aug 25 '22 16:08 aucampia

Any updates on this? @aucampia

zero0nee avatar Nov 01 '22 14:11 zero0nee

Just made a PR. @aucampia

zero0nee avatar Nov 16 '22 12:11 zero0nee

The problem seems to stem from the following line due to the fact that sep is no longer a part of posixpath.

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

aucampia avatar Nov 18 '22 21:11 aucampia

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.

aucampia avatar May 22 '23 23:05 aucampia