An invalid .sublime-package leads to UnboundLocalError: the except branch reports the problem but does not return
In ExtractSublimePackage.py (lines ~57-61):
try:
arc = zipfile.ZipFile(filename)
except zipfile.BadZipfile:
# can't open the file
_msg("package file %s is invalid" % base_name)
with contextlib.closing(arc):
After a BadZipfile the message is shown but execution continues into with contextlib.closing(arc): where arc was never assigned, so the command raises UnboundLocalError: local variable 'arc' referenced before assignment (in addition to the message). The original intent is clearly "report and stop".
Fix: add return after the _msg(...) call.
Found while testing packages from the Package Control catalog (source review).
Claude reports: closing this after 30 days with no response. Reopen it if it is still relevant.
I would rather deprecate the package and/or remove it from the listing than fix any misbehavior of it. The package supports and advertises anti-patterns.