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")
Yesterday, I have fixed an issue in bpo and this issue was for the support of
os.PathLikeinFileCookieJar. Since the introduction ofos.PathLikeand__fspath__, we continue to convert some parts of code to beos.PathLikecompliant 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.PathLikeobject?