Skip to content

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

Description

@dpc00

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions