Description
Found multiple bare except: patterns that swallow KeyboardInterrupt and SystemExit, and file handle leaks from missing with context managers.
Issues fixed
Bare except: (5 locations in 3 files):
python_executor.py: 3 bare except: in code execution path — makes the process unkillable when hanging
format_utils.py: 1 bare except: — swallows KeyboardInterrupt during title extraction
modeling_flash_llama.py: 1 bare except: — flash-attn version fallback
File handle leaks (2 locations in 1 file):
mathbook_question_extract.py: json.load(open(...)) without context manager — file descriptors not closed
Fix
- Changed all bare
except: to except Exception: or except AttributeError: (more specific)
- Changed
json.load(open(...)) to with open(...) as f: json.load(f)
[See PR for details]
Description
Found multiple bare
except:patterns that swallowKeyboardInterruptandSystemExit, and file handle leaks from missingwithcontext managers.Issues fixed
Bare
except:(5 locations in 3 files):python_executor.py: 3 bareexcept:in code execution path — makes the process unkillable when hangingformat_utils.py: 1 bareexcept:— swallowsKeyboardInterruptduring title extractionmodeling_flash_llama.py: 1 bareexcept:— flash-attn version fallbackFile handle leaks (2 locations in 1 file):
mathbook_question_extract.py:json.load(open(...))without context manager — file descriptors not closedFix
except:toexcept Exception:orexcept AttributeError:(more specific)json.load(open(...))towith open(...) as f: json.load(f)[See PR for details]