From 60cf5ada92bd15a9dbfef5d5db8d185563ec28af Mon Sep 17 00:00:00 2001 From: DeepMind Date: Fri, 20 Sep 2024 13:13:58 -0700 Subject: [PATCH] #androidenv Fix broad exception in task_manager.py This CL changes the broad exception to a list of specific exceptions that are likely to occur when parsing extras. PiperOrigin-RevId: 676946964 --- android_env/components/task_manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android_env/components/task_manager.py b/android_env/components/task_manager.py index 7332129..ef5b1cf 100644 --- a/android_env/components/task_manager.py +++ b/android_env/components/task_manager.py @@ -330,7 +330,13 @@ def _extras_handler(event, match): 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