Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Envars: Fix unbound locals #1615

Merged
merged 1 commit into from
Feb 13, 2025
Merged

Conversation

dgmcdona
Copy link
Contributor

Technically, these were protected against UnboundLocalError exceptions through the use of the sys and ntuser boolean variables, but this really isn't the best way to prevent that from happening, and type-checkers still warn about the potentially unbound locals. This fix instead uses the sys and ntuser variables to hold the registry keys, preinitializing them to None and checking their value before attempting to access instance methods.

Technically, these were protected against `UnboundLocalError` exceptions
through the use of the `sys` and `ntuser` boolean variables, but this
really isn't the best way to prevent that from happening, and
type-checkers still warn about the potentially unbound locals. This fix
instead uses the `sys` and `ntuser` variables to hold the registry keys,
preinitializing them to `None` and checking their value before
attempting to access instance methods.
Copy link
Member

@ikelos ikelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a reasonable change. No point using extra variables when it can tell us directly whether they're valid or not...

@ikelos ikelos merged commit 575e645 into develop Feb 13, 2025
24 checks passed
@ikelos ikelos deleted the dgmcdona/envars_unbound_locals branch February 13, 2025 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants