[Bf-blender-cvs] [b87eaef] master: Fix T44137: bpy.path.is_subdir fails
Campbell Barton
noreply at git.blender.org
Thu Mar 26 06:33:05 CET 2015
Commit: b87eaef1f7928bd6f0e937474cf922afa4c07f83
Author: Campbell Barton
Date: Thu Mar 26 16:29:14 2015 +1100
Branches: master
https://developer.blender.org/rBb87eaef1f7928bd6f0e937474cf922afa4c07f83
Fix T44137: bpy.path.is_subdir fails
`bpy.path.is_subdir("/abc/def/ghi","/abc/de")` incorrectly returned True
===================================================================
M release/scripts/modules/bpy/path.py
===================================================================
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index 25a6c72..0012083 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -116,7 +116,11 @@ def is_subdir(path, directory):
from os.path import normpath, normcase
path = normpath(normcase(path))
directory = normpath(normcase(directory))
- return path.startswith(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)
+ return False
def clean_name(name, replace="_"):
More information about the Bf-blender-cvs
mailing list