Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support os.fspath protocol #160

Open
altendky opened this issue Jun 21, 2018 · 0 comments
Open

Support os.fspath protocol #160

altendky opened this issue Jun 21, 2018 · 0 comments
Labels

Comments

@altendky
Copy link
Collaborator

Traceback (most recent call last):
  File "/home/epc/g/34/st/sub/epyqlib/epyqlib/nvview.py", line 321, in write_to_auto_parameters
    builder.load_epp(parameter_source_path, can_path=sym)
  File "/home/epc/g/34/st/sub/epyqlib/epyqlib/autodevice/build.py", line 81, in load_epp
    matrix, = canmatrix.formats.loadp(can_path).values()
  File "/home/epc/g/34/st/venv/src/canmatrix/canmatrix/formats.py", line 59, in loadp
    if path.endswith(extension) and "load" in supportedFormats[supportedImportType]:
AttributeError: 'PosixPath' object has no attribute 'endswith'

https://docs.python.org/3/library/os.html#os.fspath (note both os.fspath() and os.PathLike)

I'm not sure the proper idiom for handling this in a polyglot way (anything less than 3.6 in this case), but it would be nice moving forward.

Maybe in a utils module there would be:

def fspath(path):
    if sys.version < (3, 6):
        return path

    return os.fspath(path)
@ebroecker ebroecker added the bug label Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants