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 pathlib.Path objects for paths #337

Closed
nvllsvm opened this issue Jan 20, 2018 · 1 comment
Closed

Support pathlib.Path objects for paths #337

nvllsvm opened this issue Jan 20, 2018 · 1 comment
Labels

Comments

@nvllsvm
Copy link
Contributor

@nvllsvm nvllsvm commented Jan 20, 2018

The pathlib module was added to the standard library in Python 3.4. The expected behavior is to be able to path either a string or a pathlib.Path object when referencing a file or directory. For example, this behavior is demonstrated in open, gzip.open, and os.walk.

Example expected behavior in mutagen:

import pathlib
from mutagen.id3 import ID3

path = pathlib.Path('somefile.mp3')
audio = ID3(path)

Workaround:
Casting the pathlib.Pathobject as as a string.

import pathlib
from mutagen.id3 import ID3

path = pathlib.Path('somefile.mp3')
audio = ID3(str(path))
@lazka lazka added the enhancement label Jan 20, 2018
@lazka

This comment has been minimized.

Copy link
Member

@lazka lazka commented Jan 20, 2018

Supporting __fspath__ would make this work as well for 3.6+ (http://legacy.python.org/dev/peps/pep-0519/). Would that work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.