File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,14 @@ the :mod:`glob` module.)
354
354
is raised. If *strict * is ``False ``, the path is resolved as far as possible
355
355
and any remainder is appended without checking whether it exists.
356
356
357
+ .. note ::
358
+ This function emulates the operating system's procedure for making a path
359
+ canonical, which differs slightly between Windows and UNIX with respect
360
+ to how links and subsequent path components interact.
361
+
362
+ Operating system APIs make paths canonical as needed, so it's not
363
+ normally necessary to call this function.
364
+
357
365
.. versionchanged :: 3.6
358
366
Accepts a :term: `path-like object `.
359
367
Original file line number Diff line number Diff line change @@ -368,6 +368,9 @@ def test_realpath_symlink_loops(self):
368
368
self .assertRaises (OSError , ntpath .realpath , ABSTFN + "1" )
369
369
self .assertRaises (OSError , ntpath .realpath , ABSTFN + "2" )
370
370
self .assertRaises (OSError , ntpath .realpath , ABSTFN + "1\\ x" )
371
+
372
+ # Windows eliminates '..' components before resolving links, so the
373
+ # following 3 realpath() calls are not expected to raise.
371
374
self .assertPathEqual (ntpath .realpath (ABSTFN + "1\\ .." ),
372
375
ntpath .dirname (ABSTFN ))
373
376
self .assertPathEqual (ntpath .realpath (ABSTFN + "1\\ ..\\ x" ),
You can’t perform that action at this time.
0 commit comments