decalage2 / olefile

olefile is a Python package to parse, read and write Microsoft OLE2 files (also called Structured Storage, Compound File Binary Format or Compound Document File Format), such as Microsoft Office 97-2003 documents, vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files, Outlook messages, StickyNotes, several Microscopy file formats, McAfee antivirus quarantine files, etc.
http://www.decalage.info/olefile
Other
231 stars 77 forks source link

Change from catching BaseException to Exception. #153

Open TheElementalOfDestruction opened 1 year ago

TheElementalOfDestruction commented 1 year ago

olefile version 0.46 and 0.47.dev4 (master branch)

I've noticed that a number of the try-except blocks are specifically catching BaseException instead of Exception, which could lead to strange issues of exceptions being silenced where they should not (for example, KeyboardInterrupt and SystemExit). Looking through the code it appears that all of the exceptions raised (the ones that should be caught) will be subclasses of Exception and not BaseException, so there is no immediately obvious reason to catch BaseException instead.

These sections are overall so short that this issue coming up should be rare, but it does still appear to be possible.

These catches can be seen on lines 2163, 2185, 2502, and 2509 of olefile.py on the master branch.