<p dir="ltr">I like __fspath__ because it looks like os.fsencode() and os.fsdecode().</p>
<p dir="ltr">Please no builtin function, we have enough of them, but make sure that the __fspath__ is accepted in all functions expecting a filename.</p>
<p dir="ltr">If you consider that a function would make your change simpler, I suggest to add os.fspath():</p>
<p dir="ltr">if isinstance(obj, str): return obj<br>
try: return obj.__fspath__<br>
except AttributeError: raise TypeError(...)</p>
<p dir="ltr">Victor</p>