[Python-checkins] bpo-26329: update os.path.normpath documentation (GH-20138) (#27095)
ambv
webhook-mailer at python.org
Mon Jul 12 11:22:38 EDT 2021
https://github.com/python/cpython/commit/47abf240365ddd54a91c6ac167900d4bf6806c4f
commit: 47abf240365ddd54a91c6ac167900d4bf6806c4f
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-07-12T17:22:33+02:00
summary:
bpo-26329: update os.path.normpath documentation (GH-20138) (#27095)
(cherry picked from commit 66c5853406bbcccecf35372795078c0641a5f385)
Co-authored-by: Furkan Onder <furkanonder at protonmail.com>
files:
M Doc/library/os.path.rst
M Lib/posixpath.py
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index d2fe4943524533..3be513e9099c78 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -340,6 +340,14 @@ the :mod:`glob` module.)
that contains symbolic links. On Windows, it converts forward slashes to
backward slashes. To normalize case, use :func:`normcase`.
+ .. note::
+ On POSIX systems, in accordance with `IEEE Std 1003.1 2013 Edition; 4.13
+ Pathname Resolution <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_,
+ if a pathname begins with exactly two slashes, the first component
+ following the leading characters may be interpreted in an implementation-defined
+ manner, although more than two leading characters shall be treated as a
+ single character.
+
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index ecb4e5a8f7072c..af2814bdb05804 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -349,6 +349,7 @@ def normpath(path):
initial_slashes = path.startswith(sep)
# POSIX allows one or two initial slashes, but treats three or more
# as single slash.
+ # (see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13)
if (initial_slashes and
path.startswith(sep*2) and not path.startswith(sep*3)):
initial_slashes = 2
More information about the Python-checkins
mailing list