forked from orbit-oss/flask
Add support for PathLike objects in static file helpers
See: https://www.python.org/dev/peps/pep-0519/ This is mostly encountered with pathlib in python 3, but this API suggests any PathLike object can be treated like a filepath with `__fspath__` function.
This commit is contained in:
parent
f7d50d4b67
commit
25de45cbb6
4 changed files with 62 additions and 5 deletions
|
|
@ -97,3 +97,12 @@ if hasattr(sys, 'pypy_version_info'):
|
|||
BROKEN_PYPY_CTXMGR_EXIT = True
|
||||
except AssertionError:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
from os import fspath
|
||||
except ImportError:
|
||||
# Backwards compatibility as proposed in PEP 0519:
|
||||
# https://www.python.org/dev/peps/pep-0519/#backwards-compatibility
|
||||
def fspath(path):
|
||||
return path.__fspath__() if hasattr(path, '__fspath__') else path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue