Skip to content

fix(uninstaller): replace WindowsError with OSError for cross-platform compatibility#444

Open
suradadhanush wants to merge 1 commit into
adeyosemanputra:masterfrom
suradadhanush:fix/uninstaller-windowserror
Open

fix(uninstaller): replace WindowsError with OSError for cross-platform compatibility#444
suradadhanush wants to merge 1 commit into
adeyosemanputra:masterfrom
suradadhanush:fix/uninstaller-windowserror

Conversation

@suradadhanush

Copy link
Copy Markdown

Problem

except WindowsError: raises NameError: name 'WindowsError' is not defined on Linux and macOS — exactly where PyGoat runs in Docker. If the exception path in is_user_admin() is triggered on a non-Windows host, the script crashes.

Fix

Replace WindowsError with OSError. On Windows, WindowsError is a subclass of OSError so behaviour is identical. On Linux/macOS, OSError is natively defined and handles the same conditions.

Testing

  • Linux: no NameError when exception path is triggered
  • Windows: OSError catches WindowsError — identical behaviour
  • Flake8 passes

…m compatibility

- WindowsError is undefined on Linux/macOS — raises NameError if exception path is hit
- OSError catches WindowsError on Windows identically — zero functional change there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant