Description
pathlib.PurePath.as_uri()
and __bytes__()
use os.fsencode()
to encode paths, which makes their results vary from system to system. In pathlib parlance these methods are "impure", and so they rightfully belong to the Path
class, not the PurePath
class.
Furthermore, the as_uri()
method may confuse users if we add an AbstractPath
class that sits between PurePath
and Path
, as the default implementation would provide a file://
URI in a naive user subclass such as S3Path
or FTPPath
. I think this helps demonstrate that file://
URIs really are a local filesystem feature, and so should not be implemented in PurePath
.
Proposal: emit deprecation warnings from as_uri()
and __bytes__()
unless isinstance(self, Path)
. In a future version of Python, move the implementations into Path
.