Skip to content

Commit

Permalink
Replace imp by importlib
Browse files Browse the repository at this point in the history
- Fixes Python 3.12 compatibility
  • Loading branch information
smathot committed Jul 17, 2024
1 parent 3d6327e commit 9cac008
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libqtopensesame/misc/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from libopensesame.py3compat import *
import os.path
import sys
import imp
import importlib.util
import qtawesome as qta
from openexp import resources
from libopensesame import misc
Expand Down Expand Up @@ -65,10 +65,12 @@ def __init__(self, main_window, theme=None):
resources[f'theme/{self.theme}']
self.theme_info = os.path.join(self.theme_folder, u"__theme__.py")
if os.path.exists(self.theme_info):
info = imp.load_source(
# Load the theme module from file
spec = importlib.util.spec_from_file_location(
self.theme,
safe_str(self.theme_info, enc=sys.getfilesystemencoding())
)
safe_str(self.theme_info, enc=sys.getfilesystemencoding()))
info = importlib.util.module_from_spec(spec)
spec.loader.exec_module(info)
with safe_open(os.path.join(self.theme_folder, info.qss)) as fd:
self._qss = fd.read()
self._icon_map = info.icon_map
Expand Down

0 comments on commit 9cac008

Please sign in to comment.