Fix TypeError when XDG_CONFIG_HOME is set in environment#147
Open
FaulkNet wants to merge 1 commit intotrackmastersteve:masterfrom
Open
Fix TypeError when XDG_CONFIG_HOME is set in environment#147FaulkNet wants to merge 1 commit intotrackmastersteve:masterfrom
FaulkNet wants to merge 1 commit intotrackmastersteve:masterfrom
Conversation
os.environ is a mapping object and must be accessed with square brackets, not called as a function. Using os.environ() raises a TypeError which is silently swallowed, leaving _theme_dir unset and causing an AttributeError on any subsequent theme operation. Fixes alienfx crashing for users who have XDG_CONFIG_HOME set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
os.environis a mapping object and must be accessed with square brackets ([]), not called as a function (()).In
themefile.py, line 79 usesos.environ("XDG_CONFIG_HOME")which raises aTypeErrorfor any user who hasXDG_CONFIG_HOMEset in their environment. This exception is silently caught by the surroundingtry/except, leavingself._theme_dirunset. Any subsequent operation that accessesself._theme_dirthen raises anAttributeError, preventing alienfx from applying any theme.Fix
Test plan
XDG_CONFIG_HOMEin your environmentalienfx --theme <name>and confirm it applies without errorXDG_CONFIG_HOMEand confirm default~/.config/alienfxpath still works