about summary refs log tree commit diff
path: root/youtube_dl/update.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-05-22 10:06:45 +0600
committerSergey M․ <dstftw@gmail.com>2016-05-22 10:06:45 +0600
commite9297256d405651428d5d52f0bb6b32ca66ea15a (patch)
tree0862b196db33b7dd66d3db92494f0cad948ef152 /youtube_dl/update.py
parente5871c672b32d30fe4a943ad1375a7000829f03c (diff)
downloadyoutube-dl-e9297256d405651428d5d52f0bb6b32ca66ea15a.tar.gz
youtube-dl-e9297256d405651428d5d52f0bb6b32ca66ea15a.tar.xz
youtube-dl-e9297256d405651428d5d52f0bb6b32ca66ea15a.zip
[update] Fix youtube-dl.exe updating from arbitrary directory (Closes #2718)
Diffstat (limited to 'youtube_dl/update.py')
-rw-r--r--youtube_dl/update.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/youtube_dl/update.py b/youtube_dl/update.py
index 676ebe1c4..ebce9666a 100644
--- a/youtube_dl/update.py
+++ b/youtube_dl/update.py
@@ -83,11 +83,8 @@ def update_self(to_screen, verbose, opener):
 
     print_notes(to_screen, versions_info['versions'])
 
-    filename = sys.argv[0]
-    # Py2EXE: Filename could be different
-    if hasattr(sys, 'frozen') and not os.path.isfile(filename):
-        if os.path.isfile(filename + '.exe'):
-            filename += '.exe'
+    # sys.executable is set to the full pathname of the exe-file for py2exe
+    filename = sys.executable if hasattr(sys, 'frozen') else sys.argv[0]
 
     if not os.access(filename, os.W_OK):
         to_screen('ERROR: no write permissions on %s' % filename)
@@ -95,7 +92,7 @@ def update_self(to_screen, verbose, opener):
 
     # Py2EXE
     if hasattr(sys, 'frozen'):
-        exe = os.path.abspath(filename)
+        exe = filename
         directory = os.path.dirname(exe)
         if not os.access(directory, os.W_OK):
             to_screen('ERROR: no write permissions on %s' % directory)