Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-01 03:01:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-01 03:01:12 +0400
commit56e6c14e1e823da60de3bf8b21eef54b5e7d5b66 (patch)
treed19c1992a52e54152ab49608ab4d7a69b1b03eea /release/scripts/modules/console
parent6af6c96e8541c2138f5784d8b2258437d048d095 (diff)
fix for exception in console auto-completing an object with __getitem__ but no __len__ (BMEdge).
Diffstat (limited to 'release/scripts/modules/console')
-rw-r--r--release/scripts/modules/console/complete_namespace.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/release/scripts/modules/console/complete_namespace.py b/release/scripts/modules/console/complete_namespace.py
index d787fed0967..31e4f3cf225 100644
--- a/release/scripts/modules/console/complete_namespace.py
+++ b/release/scripts/modules/console/complete_namespace.py
@@ -96,12 +96,22 @@ def complete_indices(word, namespace, obj=None, base=None):
if not hasattr(obj, '__getitem__'):
# obj is not a list or dictionary
return []
- if is_dict(obj):
+
+ obj_is_dict = is_dict(obj)
+
+ # rare objects have a __getitem__ but no __len__ (eg. BMEdge)
+ if not obj_is_dict:
+ try:
+ obj_len = len(obj)
+ except TypeError:
+ return []
+
+ if obj_is_dict:
# dictionary type
matches = ['%s[%r]' % (base, key) for key in sorted(obj.keys())]
else:
- # list type
- matches = ['%s[%d]' % (base, idx) for idx in range(len(obj))]
+ # list type,
+ matches = ['%s[%d]' % (base, idx) for idx in range(obj_len)]
if word != base:
matches = [match for match in matches if match.startswith(word)]
return matches