Skip to content

Commit 443db64

Browse files
bpo-26329: update os.path.normpath documentation (GH-20138) (GH-27094)
(cherry picked from commit 66c5853) Co-authored-by: Furkan Onder <[email protected]>
1 parent 42da46e commit 443db64

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Doc/library/os.path.rst

+8
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ the :mod:`glob` module.)
340340
that contains symbolic links. On Windows, it converts forward slashes to
341341
backward slashes. To normalize case, use :func:`normcase`.
342342

343+
.. note::
344+
On POSIX systems, in accordance with `IEEE Std 1003.1 2013 Edition; 4.13
345+
Pathname Resolution <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_,
346+
if a pathname begins with exactly two slashes, the first component
347+
following the leading characters may be interpreted in an implementation-defined
348+
manner, although more than two leading characters shall be treated as a
349+
single character.
350+
343351
.. versionchanged:: 3.6
344352
Accepts a :term:`path-like object`.
345353

Lib/posixpath.py

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def normpath(path):
352352
initial_slashes = path.startswith(sep)
353353
# POSIX allows one or two initial slashes, but treats three or more
354354
# as single slash.
355+
# (see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13)
355356
if (initial_slashes and
356357
path.startswith(sep*2) and not path.startswith(sep*3)):
357358
initial_slashes = 2

0 commit comments

Comments
 (0)