This change implements support for "PathLike" objects being passed into
magic.from_file as the filename parameter. An example of this might be
using a pathlib.Path object. Python's own open() function supports
the use of PathLike objects as do many other projects. See
PEP-519 for more info.
Caveats
os.PathLike is not available on Python 2.7 or 3.5 (or earlier). Both of these are EOL (AFAIK) but python-magic is marked as supporting earlier versions in setup.py as well as including tests for py2.7 and py3.5 (which fail).
I could add the logic to test the version and enable detection? (Actually, probably the best way would be to use a simple try/except ImportError)
I wasn't sure what the policy was on python-magic EOLing py2.7/3.5....
Change Notes
This change implements support for "PathLike" objects being passed into
magic.from_file
as the filename parameter. An example of this might be using apathlib.Path
object. Python's ownopen()
function supports the use of PathLike objects as do many other projects. See PEP-519 for more info.Caveats
os.PathLike
is not available on Python 2.7 or 3.5 (or earlier). Both of these are EOL (AFAIK) butpython-magic
is marked as supporting earlier versions insetup.py
as well as including tests for py2.7 and py3.5 (which fail).I could add the logic to test the version and enable detection? (Actually, probably the best way would be to use a simple
try/except ImportError
)I wasn't sure what the policy was on python-magic EOLing py2.7/3.5....