[Bf-blender-cvs] [5e92d12] blender-v2.74-release: Fix T44137: bpy.path.is_subdir fails
Campbell Barton
noreply at git.blender.org
Tue Mar 31 15:18:54 CEST 2015
Commit: 5e92d1254e31dd3d5d43a24254bc6f32d5bd40a5
Author: Campbell Barton
Date: Thu Mar 26 16:29:14 2015 +1100
Branches: blender-v2.74-release
https://developer.blender.org/rB5e92d1254e31dd3d5d43a24254bc6f32d5bd40a5
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