[Bf-blender-cvs] [aa523f8] master: Fix os.path.is_subdir w/ trailing slash

Campbell Barton noreply at git.blender.org
Tue Jan 12 17:08:28 CET 2016


Commit: aa523f8435d209559749bbafeee82ad964726a0f
Author: Campbell Barton
Date:   Wed Jan 13 02:58:53 2016 +1100
Branches: master
https://developer.blender.org/rBaa523f8435d209559749bbafeee82ad964726a0f

Fix os.path.is_subdir w/ trailing slash

===================================================================

M	release/scripts/modules/bpy/path.py

===================================================================

diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index d7c6101..db4c8da 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -118,13 +118,13 @@ def is_subdir(path, directory):
     :arg path: An absolute path.
     :type path: string or bytes
     """
-    from os.path import normpath, normcase
+    from os.path import normpath, normcase, sep
     path = normpath(normcase(path))
     directory = normpath(normcase(directory))
     if len(path) > len(directory):
-        if path.startswith(directory):
-            sep = ord(_os.sep) if isinstance(directory, bytes) else _os.sep
-            return (path[len(directory)] == sep)
+        sep = sep.encode('ascii') if isinstance(directory, bytes) else sep
+        if path.startswith(directory.rstrip(sep) + sep):
+            return True
     return False




More information about the Bf-blender-cvs mailing list