Concatenate str only in os.path.join
authorgfyoung <redacted>
Tue, 23 May 2017 02:50:59 +0000 (22:50 -0400)
committergfyoung <redacted>
Tue, 23 May 2017 03:31:35 +0000 (23:31 -0400)
Closes gh-316.

updateHostsFile.py

index dbe75cf5bb645c3e6256f2f4417370648b846072..b2e43bf20876ef7aa2f81ead42b9c0ce93f30ec8 100644 (file)
@@ -728,7 +728,8 @@ def recursive_glob(stem, file_pattern):
     if sys.version_info >= (3, 5):
         return glob(stem + "/**/" + file_pattern, recursive=True)
     else:
-        if stem == "*":
+        # gh-316: this will avoid invalid unicode comparisons in Python 2.x
+        if stem == str("*"):
             stem = "."
         matches = []
         for root, dirnames, filenames in os.walk(stem):
@@ -759,6 +760,10 @@ def path_join_robust(path, *paths):
     """
 
     try:
+        # gh-316: joining unicode and str can be saddening in Python 2.x
+        path = str(path)
+        paths = [str(another_path) for another_path in paths]
+
         return os.path.join(path, *paths)
     except UnicodeDecodeError as e:
         raise locale.Error("Unable to construct path. This is "
git clone https://git.99rst.org/PROJECT