Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Created September 24, 2014 19:04
Show Gist options
  • Save jimblandy/0f9abe07999e107e8dcf to your computer and use it in GitHub Desktop.
Save jimblandy/0f9abe07999e107e8dcf to your computer and use it in GitHub Desktop.
On OSX, the PATH environment variable may contain non-ASCII characters; python/which/which.py should handle those.
diff --git a/python/which/which.py b/python/which/which.py
--- a/python/which/which.py
+++ b/python/which/which.py
@@ -158,16 +158,18 @@ def whichgen(command, path=None, verbose
command>, <where path found>).
"""
matches = []
if path is None:
usingGivenPath = 0
path = os.environ.get("PATH", "").split(os.pathsep)
if sys.platform.startswith("win"):
path.insert(0, os.curdir) # implied by Windows shell
+ if sys.platform == "darwin":
+ path = unicode(path, 'utf-8')
else:
usingGivenPath = 1
# Windows has the concept of a list of extensions (PATHEXT env var).
if sys.platform.startswith("win"):
if exts is None:
exts = os.environ.get("PATHEXT", "").split(os.pathsep)
# If '.exe' is not in exts then obviously this is Win9x and
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment