Fix infinite recursion on inspector
@@ -2,8 +2,12 @@ from types import ModuleType as Module
import sys
import rubicon.objc
+__inspected_times__ = {}
+
def get_variables_hierarchy(object):
+ global __inspected_times__
+
vars = {}
def represent(value_):
@@ -13,6 +17,17 @@ def get_variables_hierarchy(object):
if type(value) is Module:
value = value.__dict__
+ try:
+ if repr(value) in __inspected_times__:
+ __inspected_times__[repr(value)] = __inspected_times__[repr(value)]+1
+ else:
+ __inspected_times__[repr(value)] = 1
+
+ if __inspected_times__[repr(value)] > 5:
+ return repr(value)
+ except Exception as e:
+ print(e)
+
if type(value) is list:
i = 0
@@ -54,4 +69,6 @@ def get_variables_hierarchy(object):
for key in dir(object):
vars[key] = represent(getattr(object, key))
+ __inspected_times__ = {}
+
return vars
