Skip to content

Commit 7eeab46

Browse files
improve range check
1 parent ad4e223 commit 7eeab46

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

sentry_sdk/tracing.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -981,16 +981,15 @@ def _in_http_status_code_range(self, code, code_ranges):
981981

982982
wrong_type_message = "trace_ignore_status_codes must be a list of integers or pairs of integers."
983983
try:
984-
if (
985-
len(target) == 2
986-
and isinstance(target[0], int)
987-
and isinstance(target[1], int)
988-
and target[0] <= code <= target[1]
989-
):
990-
return True
991-
elif not isinstance(target[0], int) or not isinstance(target[1], int):
984+
low, high = target
985+
if not isinstance(target[0], int) or not isinstance(target[1], int):
992986
logger.warning(wrong_type_message)
993-
except (TypeError, IndexError):
987+
continue
988+
989+
if low <= code <= high:
990+
return True
991+
992+
except Exception:
994993
logger.warning(wrong_type_message)
995994

996995
return False

0 commit comments

Comments
 (0)