@@ -1858,6 +1858,12 @@ features:
18581858 .. versionchanged :: 3.6
18591859 Accepts a :term: `path-like object ` for *src * and *dst *.
18601860
1861+ .. versionchanged :: 3.8
1862+ On Windows, now opens reparse points that represent another path
1863+ (name surrogates), including symbolic links and directory junctions.
1864+ Other kinds of reparse points are resolved by the operating system as
1865+ for :func: `~os.stat `.
1866+
18611867
18621868.. function :: mkdir(path, mode=0o777, *, dir_fd=None)
18631869
@@ -2039,6 +2045,10 @@ features:
20392045 This function can also support :ref: `paths relative to directory descriptors
20402046 <dir_fd>`.
20412047
2048+ When trying to resolve a path that may contain links, use
2049+ :func: `~os.path.realpath ` to properly handle recursion and platform
2050+ differences.
2051+
20422052 .. availability :: Unix, Windows.
20432053
20442054 .. versionchanged :: 3.2
@@ -2053,6 +2063,11 @@ features:
20532063 .. versionchanged :: 3.8
20542064 Accepts a :term: `path-like object ` and a bytes object on Windows.
20552065
2066+ .. versionchanged :: 3.8
2067+ Added support for directory junctions, and changed to return the
2068+ substitution path (which typically includes ``\\?\ `` prefix) rather
2069+ than the optional "print name" field that was previously returned.
2070+
20562071.. function :: remove(path, *, dir_fd=None)
20572072
20582073 Remove (delete) the file *path *. If *path * is a directory, an
@@ -2366,7 +2381,8 @@ features:
23662381
23672382 On Unix, this method always requires a system call. On Windows, it
23682383 only requires a system call if *follow_symlinks * is ``True `` and the
2369- entry is a symbolic link.
2384+ entry is a reparse point (for example, a symbolic link or directory
2385+ junction).
23702386
23712387 On Windows, the ``st_ino ``, ``st_dev `` and ``st_nlink `` attributes of the
23722388 :class: `stat_result ` are always set to zero. Call :func: `os.stat ` to
@@ -2403,6 +2419,17 @@ features:
24032419 This function can support :ref: `specifying a file descriptor <path_fd >` and
24042420 :ref: `not following symlinks <follow_symlinks >`.
24052421
2422+ On Windows, passing ``follow_symlinks=False `` will disable following all
2423+ name-surrogate reparse points, which includes symlinks and directory
2424+ junctions. Other types of reparse points that do not resemble links or that
2425+ the operating system is unable to follow will be opened directly. When
2426+ following a chain of multiple links, this may result in the original link
2427+ being returned instead of the non-link that prevented full traversal. To
2428+ obtain stat results for the final path in this case, use the
2429+ :func: `os.path.realpath ` function to resolve the path name as far as
2430+ possible and call :func: `lstat ` on the result. This does not apply to
2431+ dangling symlinks or junction points, which will raise the usual exceptions.
2432+
24062433 .. index :: module: stat
24072434
24082435 Example::
@@ -2427,6 +2454,14 @@ features:
24272454 .. versionchanged :: 3.6
24282455 Accepts a :term: `path-like object `.
24292456
2457+ .. versionchanged :: 3.8
2458+ On Windows, all reparse points that can be resolved by the operating
2459+ system are now followed, and passing ``follow_symlinks=False ``
2460+ disables following all name surrogate reparse points. If the operating
2461+ system reaches a reparse point that it is not able to follow, *stat * now
2462+ returns the information for the original path as if
2463+ ``follow_symlinks=False `` had been specified instead of raising an error.
2464+
24302465
24312466.. class :: stat_result
24322467
@@ -2578,7 +2613,7 @@ features:
25782613
25792614 File type.
25802615
2581- On Windows systems, the following attribute is also available:
2616+ On Windows systems, the following attributes are also available:
25822617
25832618 .. attribute :: st_file_attributes
25842619
@@ -2587,6 +2622,12 @@ features:
25872622 :c:func: `GetFileInformationByHandle `. See the ``FILE_ATTRIBUTE_* ``
25882623 constants in the :mod: `stat ` module.
25892624
2625+ .. attribute :: st_reparse_tag
2626+
2627+ When :attr: `st_file_attributes ` has the ``FILE_ATTRIBUTE_REPARSE_POINT ``
2628+ set, this field contains the tag identifying the type of reparse point.
2629+ See the ``IO_REPARSE_TAG_* `` constants in the :mod: `stat ` module.
2630+
25902631 The standard module :mod: `stat ` defines functions and constants that are
25912632 useful for extracting information from a :c:type: `stat ` structure. (On
25922633 Windows, some items are filled with dummy values.)
@@ -2614,6 +2655,14 @@ features:
26142655 .. versionadded :: 3.7
26152656 Added the :attr: `st_fstype ` member to Solaris/derivatives.
26162657
2658+ .. versionadded :: 3.8
2659+ Added the :attr: `st_reparse_tag ` member on Windows.
2660+
2661+ .. versionchanged :: 3.8
2662+ On Windows, the :attr: `st_mode ` member now identifies special
2663+ files as :const: `S_IFCHR `, :const: `S_IFIFO ` or :const: `S_IFBLK `
2664+ as appropriate.
2665+
26172666.. function :: statvfs(path)
26182667
26192668 Perform a :c:func: `statvfs ` system call on the given path. The return value is
0 commit comments