ExtractSublimePackage icon indicating copy to clipboard operation
ExtractSublimePackage copied to clipboard

An invalid .sublime-package leads to UnboundLocalError: the except branch reports the problem but does not return

Open dpc00 opened this issue 2 months ago • 2 comments

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).

dpc00 avatar Sep 25 '26 09:09 dpc00

Claude reports: closing this after 30 days with no response. Reopen it if it is still relevant.

dpc00 avatar Oct 27 '26 19:10 dpc00

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.

FichteFoll avatar Oct 28 '26 12:10 FichteFoll