Skip to content

Commit 41a09bf

Browse files
leotrubachuntitaker
authored andcommitted
Another place where errors may arise during frame traversal (getsentry#240)
* Handle iteration errors during frame traversal * Fixes as suggested by @untitaker * Add explanatory comments * Replace deprecated `render_to_response` with `render` * Handle only list and tuple instances in `break_cycles()` * Add comment to changes to `break_cycles()` logic
1 parent e47a4d5 commit 41a09bf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sentry_sdk/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,9 @@ def break_cycles(obj, memo=None):
633633
try:
634634
if isinstance(obj, Mapping):
635635
return {k: break_cycles(v, memo) for k, v in obj.items()}
636-
if isinstance(obj, Sequence) and not isinstance(obj, (text_type, bytes)):
636+
if isinstance(obj, (list, tuple)):
637+
# It is not safe to iterate over another sequence types as this may raise errors or
638+
# bring undesired side-effects (e.g. Django querysets are executed during iteration)
637639
return [break_cycles(v, memo) for v in obj]
638640
return obj
639641
finally:

0 commit comments

Comments
 (0)