-
Notifications
You must be signed in to change notification settings - Fork 14
Improve import error detection so the plugin does not throw errors in headless mode #9
Copy link
Copy link
Open
Description
Recently when I tried to run IDA in headleass mode via scripting in Claude Code, I noticed that the following error is thrown by this plugin:
Traceback (most recent call last):
File "H:\ida/plugins\pyclassinformer\qtutils.py", line 10, in can_use_qt
import sip
ModuleNotFoundError: No module named 'sip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "H:\ida/plugins\pyclassinformer\qtutils.py", line 131, in ready_to_run
self.enable_toolbar()
~~~~~~~~~~~~~~~~~~~^^
File "H:\ida/plugins\pyclassinformer\qtutils.py", line 135, in enable_toolbar
set_toobar_visible(widget, self.toolbar_name)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "H:\ida/plugins\pyclassinformer\qtutils.py", line 106, in set_toobar_visible
if not can_use_qt():
~~~~~~~~~~^^
File "H:\ida/plugins\pyclassinformer\qtutils.py", line 17, in can_use_qt
from PySide6 import QtCore
File "H:\ida\python\PySide6\__init__.py", line 26, in <module>
_verify_prerequisites()
~~~~~~~~~~~~~~~~~~~~~^^
File "H:\ida\python\PySide6\__init__.py", line 19, in _verify_prerequisites
raise ImportError("PySide6 can only be used from the GUI version of IDA")
ImportError: PySide6 can only be used from the GUI version of IDA
Although there is existing exception handling, it does not catch the error when running in headless mode.
Here's the analysis Claude gives:
What was wrong: The pyclassinformer IDA plugin's qtutils.py had a broken exception handling pattern when PyQt5 import failed with ModuleNotFoundError (subclass of ImportError), it fell into except ImportError and tried PySide6, which also failed in headless mode. That second failure wasn't caught.
Fix: Wrapped all PySide6 fallback imports in their own try/except (ImportError, ModuleNotFoundError) blocks across 8 functions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels