summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-02-08 19:36:55 +0700
committerSergey M․ <dstftw@gmail.com>2020-02-08 19:36:55 +0700
commit82fea5b42eadc4ac2d3f4f688613f140967e92b7 (patch)
treee0b054329a0adca6a4252b70e07bc8e51f5e1f07
parentfffc618c519d10a7335eb5b06ab13d56ecea8561 (diff)
downloadyoutube-dl-82fea5b42eadc4ac2d3f4f688613f140967e92b7.tar.gz
youtube-dl-82fea5b42eadc4ac2d3f4f688613f140967e92b7.tar.xz
youtube-dl-82fea5b42eadc4ac2d3f4f688613f140967e92b7.zip
[compat] Introduce compat_realpath (refs #23991)
-rw-r--r--youtube_dl/compat.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index c75ab131b..062b338d7 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -2754,6 +2754,17 @@ else:
         compat_expanduser = os.path.expanduser
 
 
+if compat_os_name == 'nt' and sys.version_info < (3, 8):
+    # os.path.realpath on Windows does not follow symbolic links
+    # prior to Python 3.8 (see https://bugs.python.org/issue9949)
+    def compat_realpath(path):
+        while os.path.islink(path):
+            path = os.path.abspath(os.readlink(path))
+        return path
+else:
+    compat_realpath = os.path.realpath
+
+
 if sys.version_info < (3, 0):
     def compat_print(s):
         from .utils import preferredencoding