Browse Source

python script core: shutil_which() exception fix for Python 3 (fixes https://trac.osgeo.org/grass/ticket/3773)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74225 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 6 years ago
parent
commit
b660ed52da
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lib/python/script/core.py

+ 3 - 1
lib/python/script/core.py

@@ -164,7 +164,7 @@ def get_commands():
 
 
     return set(cmd), scripts
     return set(cmd), scripts
 
 
-
+# TODO: Please replace this function with shutil.which() before 8.0 comes out
 # replacement for which function from shutil (not available in all versions)
 # replacement for which function from shutil (not available in all versions)
 # from http://hg.python.org/cpython/file/6860263c05b3/Lib/shutil.py#l1068
 # from http://hg.python.org/cpython/file/6860263c05b3/Lib/shutil.py#l1068
 # added because of Python scripts running Python scripts on MS Windows
 # added because of Python scripts running Python scripts on MS Windows
@@ -239,6 +239,8 @@ def shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):
                     return name
                     return name
     return None
     return None
 
 
+if sys.version_info.major > 2:
+    shutil_which = shutil.which
 
 
 # Added because of scripts calling scripts on MS Windows.
 # Added because of scripts calling scripts on MS Windows.
 # Module name (here cmd) differs from the file name (does not have extension).
 # Module name (here cmd) differs from the file name (does not have extension).