@@ -485,19 +485,6 @@ Pure paths provide the following methods and properties:
485485 'c:/windows'
486486
487487
488- .. method :: PurePath.as_uri()
489-
490- Represent the path as a ``file `` URI. :exc: `ValueError ` is raised if
491- the path isn't absolute.
492-
493- >>> p = PurePosixPath(' /etc/passwd' )
494- >>> p.as_uri()
495- 'file:///etc/passwd'
496- >>> p = PureWindowsPath(' c:/Windows' )
497- >>> p.as_uri()
498- 'file:///c:/Windows'
499-
500-
501488.. method :: PurePath.is_absolute()
502489
503490 Return whether the path is absolute or not. A path is considered absolute
@@ -813,6 +800,67 @@ bugs or failures in your application)::
813800 UnsupportedOperation: cannot instantiate 'WindowsPath' on your system
814801
815802
803+ File URIs
804+ ^^^^^^^^^
805+
806+ Concrete path objects can be created from, and represented as, 'file' URIs
807+ conforming to :rfc: `8089 `.
808+
809+ .. note ::
810+
811+ File URIs are not portable across machines with different
812+ :ref: `filesystem encodings <filesystem-encoding >`.
813+
814+ .. classmethod :: Path.from_uri(uri)
815+
816+ Return a new path object from parsing a 'file' URI. For example::
817+
818+ >>> p = Path.from_uri('file:///etc/hosts')
819+ PosixPath('/etc/hosts')
820+
821+ On Windows, DOS device and UNC paths may be parsed from URIs::
822+
823+ >>> p = Path.from_uri('file:///c:/windows')
824+ WindowsPath('c:/windows')
825+ >>> p = Path.from_uri('file://server/share')
826+ WindowsPath('//server/share')
827+
828+ Several variant forms are supported::
829+
830+ >>> p = Path.from_uri('file:////server/share')
831+ WindowsPath('//server/share')
832+ >>> p = Path.from_uri('file://///server/share')
833+ WindowsPath('//server/share')
834+ >>> p = Path.from_uri('file:c:/windows')
835+ WindowsPath('c:/windows')
836+ >>> p = Path.from_uri('file:/c|/windows')
837+ WindowsPath('c:/windows')
838+
839+ :exc: `ValueError ` is raised if the URI does not start with ``file: ``, or
840+ the parsed path isn't absolute.
841+
842+ .. versionadded :: 3.13
843+
844+
845+ .. method :: Path.as_uri()
846+
847+ Represent the path as a 'file' URI. :exc: `ValueError ` is raised if
848+ the path isn't absolute.
849+
850+ .. code-block :: pycon
851+
852+ >>> p = PosixPath('/etc/passwd')
853+ >>> p.as_uri()
854+ 'file:///etc/passwd'
855+ >>> p = WindowsPath('c:/Windows')
856+ >>> p.as_uri()
857+ 'file:///c:/Windows'
858+
859+ For historical reasons, this method is also available from
860+ :class: `PurePath ` objects. However, its use of :func: `os.fsencode ` makes
861+ it strictly impure.
862+
863+
816864Methods
817865^^^^^^^
818866
@@ -853,42 +901,6 @@ call fails (for example because the path doesn't exist).
853901 .. versionadded :: 3.5
854902
855903
856- .. classmethod :: Path.from_uri(uri)
857-
858- Return a new path object from parsing a 'file' URI conforming to
859- :rfc: `8089 `. For example::
860-
861- >>> p = Path.from_uri('file:///etc/hosts')
862- PosixPath('/etc/hosts')
863-
864- On Windows, DOS device and UNC paths may be parsed from URIs::
865-
866- >>> p = Path.from_uri('file:///c:/windows')
867- WindowsPath('c:/windows')
868- >>> p = Path.from_uri('file://server/share')
869- WindowsPath('//server/share')
870-
871- Several variant forms are supported::
872-
873- >>> p = Path.from_uri('file:////server/share')
874- WindowsPath('//server/share')
875- >>> p = Path.from_uri('file://///server/share')
876- WindowsPath('//server/share')
877- >>> p = Path.from_uri('file:c:/windows')
878- WindowsPath('c:/windows')
879- >>> p = Path.from_uri('file:/c|/windows')
880- WindowsPath('c:/windows')
881-
882- :exc: `ValueError ` is raised if the URI does not start with ``file: ``, or
883- the parsed path isn't absolute.
884-
885- :func: `os.fsdecode ` is used to decode percent-escaped byte sequences, and
886- so file URIs are not portable across machines with different
887- :ref: `filesystem encodings <filesystem-encoding >`.
888-
889- .. versionadded :: 3.13
890-
891-
892904.. method :: Path.stat(*, follow_symlinks=True)
893905
894906 Return a :class: `os.stat_result ` object containing information about this path, like :func: `os.stat `.
0 commit comments