Skip to content

FIX: util module import to prevent name collisions#13492

Merged
mtwebster merged 1 commit into
linuxmint:masterfrom
carsteneu:fix-issue-13490-util-import
Jan 27, 2026
Merged

FIX: util module import to prevent name collisions#13492
mtwebster merged 1 commit into
linuxmint:masterfrom
carsteneu:fix-issue-13490-util-import

Conversation

@carsteneu
Copy link
Copy Markdown
Contributor

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 util to from bin import util in:

  • bin/KeybindingWidgets.py
  • bin/SettingsWidgets.py
  • bin/XkbSettings.py
  • modules/cs_sound.py

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:

  • cinnamon-settings launches without errors
  • Sound settings module loads correctly
  • Keyboard settings with XKB options tab works

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.

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
@mtwebster
Copy link
Copy Markdown
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 strip_syspath_locals()

Running:

touch ~/util.py
PYTHONPATH=~ cinnamon-settings

is the only way I can get an error.

@mtwebster mtwebster merged commit 0344b11 into linuxmint:master Jan 27, 2026
4 checks passed
mtwebster pushed a commit that referenced this pull request Feb 9, 2026
…13492)

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 #13490
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.

2 participants