FIX: util module import to prevent name collisions#13492
Merged
mtwebster merged 1 commit intoJan 27, 2026
Conversation
Use explicit 'from bin import util' instead of bare 'import util' to prevent conflicts with local util.py files in the user's working directory or Python path. Fixes linuxmint#13490
Member
|
I'm not able to reproduce this - placing a util.py in my home directory makes no difference unless that directory has been added to PYTHONPATH for some reason. I'm not arguing against the PR but I like to be able to confirm a before/after behavior, and I'm having trouble coming up with a real-world test case - we already filter out /usr/local and ~/.local imports via Running: touch ~/util.py
PYTHONPATH=~ cinnamon-settingsis the only way I can get an error. |
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.
This PR addresses issue #13490 where cinnamon-settings fails to start with an AttributeError: module 'util' has no attribute 'get_session_type'.
The root cause appears to be the use of bare import util statements in four files, which can be shadowed by any util.py file present in the user's working directory or Python path.
I was able to reproduce this issue by placing an empty util.py in the home directory – this caused the exact error reported in the issue. After applying the fix, cinnamon-settings launched correctly even with the conflicting file present.
Changes
Changed
import utiltofrom bin import utilin:This aligns these files with the import pattern already used throughout the codebase (e.g., cinnamon-settings.py, cs_keyboard.py, cs_info.py, cs_general.py, etc.).
Tested
Tested in Linux Mint 22.3 VM:
While this issue may be relatively rare in practice (requiring a conflicting util.py in the user's environment), using explicit imports is more robust in my point of view and i think consistent with the rest of the codebase.