Skip to content

Commit bda5709

Browse files
Doc: Clarify os.fspath normalization and resolution behavior
Note that os.fspath only extracts the file system representation from a PathLike object (or returns str/bytes unchanged) without performing path normalization, validation, or component resolution. Signed-off-by: ANISAYAK MITRA <266799942+anisayakmitra-in@users.noreply.github.com>
1 parent 5dbe2ac commit bda5709

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ process and user.
320320
returned as long as it is a :class:`str` or :class:`bytes` object.
321321
In all other cases, :exc:`TypeError` is raised.
322322

323+
.. note::
324+
325+
:func:`!fspath` does not perform any path normalization, validation, or
326+
resolution of components such as ``.``, ``..``, or symbolic links.
327+
Use :func:`os.path.normpath` or :meth:`pathlib.Path.resolve` if path
328+
normalization or resolution is needed.
329+
323330
.. versionadded:: 3.6
324331

325332

0 commit comments

Comments
 (0)