Skip to content

Commit

Permalink
#androidenv Fix broad exception in task_manager.py
Browse files Browse the repository at this point in the history
This CL changes the broad exception to a list of specific exceptions that are likely to occur when parsing extras.

PiperOrigin-RevId: 676946964
  • Loading branch information
DeepMind authored and copybara-github committed Sep 24, 2024
1 parent cf08e17 commit d0a93cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions android_env/components/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,13 @@ def _extras_handler(event, match):
if extra:
try:
extra = ast.literal_eval(extra)
# Except all to avoid unnecessary crashes, only log error.
except Exception: # pylint: disable=broad-except
except (
ValueError,
TypeError,
SyntaxError,
MemoryError,
RecursionError,
):
logging.exception('Could not parse extra: %s', extra)
# Don't try to process the extra as text; that would probably crash.
return
Expand Down

0 comments on commit d0a93cd

Please sign in to comment.