We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
utils
1 parent 38bbc9c commit 7ecb533Copy full SHA for 7ecb533
unification/utils.py
@@ -15,13 +15,13 @@ def transitive_get(key, d):
15
>>> transitive_get(1, d)
16
4
17
"""
18
- for _ in range(len(d)):
19
- key = d[key]
20
-
21
- with suppress(TypeError):
22
- if key in d:
23
- continue
24
- break
+ for _ in range(len(d) + 1):
+ try:
+ if key not in d:
+ break
+ key = d[key]
+ except TypeError:
25
else:
26
raise RecursionError("dict contains a loop")
27
@@ -99,6 +99,8 @@ def freeze(d):
99
>>> freeze({1: 2}) # doctest: +SKIP
100
((1, 2),)
101
102
+ if isinstance(d, (str, bytes)):
103
+ return d
104
if isinstance(d, Mapping):
105
if __PY37:
106
items = d.items()
0 commit comments