From 78a480aa0881e1e9bde80eac7b97ed167cacce99 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Tue, 12 Jun 2018 14:45:15 -0400 Subject: [PATCH] Change str.isdecimal to isdigit. On lists keep iterating if unless index is found --- stix2/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stix2/utils.py b/stix2/utils.py index cdbb88e..b1a7eda 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -172,11 +172,13 @@ def _iterate_over_values(dict_values, tuple_to_find): if isinstance(pv, list): for item in pv: if isinstance(item, _STIXBase): - return find_property_index( + index = find_property_index( item, item.object_properties(), tuple_to_find ) + if index is not None: + return index elif isinstance(item, dict): for idx, val in enumerate(sorted(item)): if (tuple_to_find[0] == val and @@ -184,7 +186,7 @@ def _iterate_over_values(dict_values, tuple_to_find): return idx elif isinstance(pv, dict): for idx, item in enumerate(sorted(pv.keys())): - if ((item == tuple_to_find[0] and str.isdecimal(item)) and + if ((item == tuple_to_find[0] and str.isdigit(item)) and (pv[item] == tuple_to_find[1])): return int(tuple_to_find[0]) elif pv[item] == tuple_to_find[1]: