##// END OF EJS Templates
Limit unwrapping __wrapped__ attributes to prevent infinite loops...
Thomas Kluyver -
Show More
@@ -280,9 +280,21 b' def call_tip(oinfo, format_call=True):'
280
280
281
281
282 def _get_wrapped(obj):
282 def _get_wrapped(obj):
283 """Get the original object if wrapped in one or more @decorators"""
283 """Get the original object if wrapped in one or more @decorators
284
285 Some objects automatically construct similar objects on any unrecognised
286 attribute access (e.g. unittest.mock.call). To protect against infinite loops,
287 this will arbitrarily cut off after 100 levels of obj.__wrapped__
288 attribute access. --TK, Jan 2016
289 """
290 orig_obj = obj
291 i = 0
284 while safe_hasattr(obj, '__wrapped__'):
292 while safe_hasattr(obj, '__wrapped__'):
285 obj = obj.__wrapped__
293 obj = obj.__wrapped__
294 i += 1
295 if i > 100:
296 # __wrapped__ is probably a lie, so return the thing we started with
297 return orig_obj
286 return obj
298 return obj
287
299
288 def find_file(obj):
300 def find_file(obj):
General Comments 0
You need to be logged in to leave comments. Login now