GeezerVison is showing github.com — fixing RecursionError where using non UTF-8 character #227 · FOSSAware/deepdiff@1e1df14
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: CHANGELOG.md +2-1Lines changed: 2 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -DeepDiff Change log | | 1 | +# DeepDiff Change log | 2 | 2 |
| | 3 | +- v5-2-3: Retaining the order of multiple dictionary items added via Delta. Fixed the typo with yml files in deep cli. Fixing Grep RecursionError where using non UTF-8 character. | 3 | 4 | - v5-2-2: Fixed Delta serialization when None type is present. | 4 | 5 | - v5-2-0: Removed Murmur3 as the preferred hashing method. Using SHA256 by default now. Added commandline for deepdiff. Added group_by. Added math_epsilon. Improved ignoring of NoneType. | 5 | 6 | - v5-0-2: Bug Fix NoneType in ignore type groups https://github.com/seperman/deepdiff/issues/207 | |
Collapse file Copy file name to clipboardExpand all lines: deepdiff/search.py +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -223,7 +223,6 @@ def __search_iterable(self, | 223 | 223 | parent="root", | 224 | 224 | parents_ids=frozenset()): | 225 | 225 | """Search iterables except dictionaries, sets and strings.""" | 226 | | - | 227 | 226 | for i, thing in enumerate(obj): | 228 | 227 | new_parent = "{}[{}]".format(parent, i) | 229 | 228 | if self.__skip_this(thing, parent=new_parent): | @@ -271,7 +270,7 @@ def __search_tuple(self, obj, item, parent, parents_ids): | 271 | 270 |
| 272 | 271 | def __search(self, obj, item, parent="root", parents_ids=frozenset()): | 273 | 272 | """The main search method""" | 274 | | - | | 273 | + # import pytest; pytest.set_trace() | 275 | 274 | if self.__skip_this(item, parent): | 276 | 275 | return | 277 | 276 |
| @@ -299,7 +298,7 @@ def __search(self, obj, item, parent="root", parents_ids=frozenset()): | 299 | 298 | self.warning_num += 1 | 300 | 299 | self.__search_iterable(obj, item, parent, parents_ids) | 301 | 300 |
| 302 | | - elif isinstance(obj, Iterable): | | 301 | + elif isinstance(obj, Iterable) and not isinstance(obj, strings): | 303 | 302 | self.__search_iterable(obj, item, parent, parents_ids) | 304 | 303 |
| 305 | 304 | else: | |
Collapse file Copy file name to clipboardExpand all lines: docs/changelog.rst +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,7 @@ Changelog | 5 | 5 |
| 6 | 6 | DeepDiff Changelog | 7 | 7 |
| | 8 | +- v5-2-3: Retaining the order of multiple dictionary items added via Delta. Fixed the typo with yml files in deep cli. Fixing Grep RecursionError where using non UTF-8 character. | 8 | 9 | - v5-2-2: Fixed Delta serialization when None type is present. | 9 | 10 | - v5-2-0: Removed Murmur3 as the preferred hashing method. Using SHA256 by default now. Added commandline for deepdiff. Added group_by. Added math_epsilon. Improved ignoring of NoneType. | 10 | 11 | - v5-0-2: Bug Fix NoneType in ignore type groups https://github.com/seperman/deepdiff/issues/207 | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_search.py +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,18 @@ def test_number_in_list(self): | 29 | 29 | result = {"matched_values": {'root[1]'}} | 30 | 30 | assert DeepSearch(obj, item, verbose_level=1) == result | 31 | 31 |
| | 32 | + def test_number_in_list2(self): | | 33 | + obj = ["a", "10", 10, 20] | | 34 | + item = 10 | | 35 | + result = {"matched_values": {'root[2]'}} | | 36 | + assert DeepSearch(obj, item, verbose_level=1) == result | | 37 | + | | 38 | + def test_number_in_list3(self): | | 39 | + obj = ["a", "10", 10, 20] | | 40 | + item = "10" | | 41 | + result = {"matched_values": {'root[1]'}} | | 42 | + assert DeepSearch(obj, item, verbose_level=1) == result | | 43 | + | 32 | 44 | def test_string_in_root(self): | 33 | 45 | obj = "long string somewhere" | 34 | 46 | result = {"matched_values": {'root'}} | @@ -334,3 +346,22 @@ def test_grep_dict(self): | 334 | 346 | } | 335 | 347 | ds = obj | grep(item) | 336 | 348 | assert ds == {'matched_values': {"root['ingredients'][3]"}} | | 349 | + | | 350 | + def test_grep_dict_in_dict(self): | | 351 | + obj = { | | 352 | + "x": { | | 353 | + "y": [ | | 354 | + "aaaaaa\u0142 bbbbb" | | 355 | + ] | | 356 | + }, | | 357 | + "z": "z", | | 358 | + } | | 359 | + item = {"z": "z"} | | 360 | + result = obj | grep(item) | | 361 | + assert {} == result | | 362 | + | | 363 | + def test_grep_with_non_utf8_chars(self): | | 364 | + obj = "aaaaaa\u0142 bbbbb" | | 365 | + item = {"z": "z"} | | 366 | + result = obj | grep(item) | | 367 | + assert {} == result |
|