Closed
Description
Yesterday, I have fixed an issue in bpo and this issue was for the support of os.PathLike
in FileCookieJar
. Since the introduction of os.PathLike
and __fspath__
, we continue to convert some parts of code to be os.PathLike
compliant and I think there is a pattern for that.
Maybe we could create a page "Patterns" with some examples.
For example (but need to be tested and approved)
How to support a os.PathLike
object?
def __init__(self, filename):
try:
filename = os.fspath(filename)
except TypeError:
raise ValueError("filename must be a string-like or path-like object")
Metadata
Metadata
Assignees
Labels
No labels