Skip to content

Commit 08ec389

Browse files
committed
Added a few fail safe
1 parent 6680a36 commit 08ec389

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

pyclassinformer/msvc_rtti.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
import ida_ida
1212
import ida_idp
1313

14+
try:
15+
ModuleNotFoundError
16+
except NameError:
17+
ModuleNotFoundError = ImportError
18+
1419
ida_9_or_later = False
1520
try:
1621
from ida_struct import get_struc
@@ -235,7 +240,7 @@ def __init__(self, ea, nb_classes):
235240
pass
236241

237242
# Sometimes, mdisp value is not included in COLs' offsets.
238-
# In that case, use either one of the following:
243+
# In that case, use either one of the followings:
239244
# - zero (before iterating BCA)
240245
# - in the middle of the BCD's mdisp of a path (for MI with multiple vftables)
241246
# - least COL's offset (for other cases such as SI and MI with a single vftable)

pyclassinformer/pci_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
import ida_name
1414
import ida_ida
1515

16+
try:
17+
ModuleNotFoundError
18+
except NameError:
19+
ModuleNotFoundError = ImportError
20+
1621
ida_9_or_later = False
1722
try:
1823
import ida_struct

pyclassinformer/qtutils.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import ida_kernwin
22

3+
try:
4+
ModuleNotFoundError
5+
except NameError:
6+
ModuleNotFoundError = ImportError
37

48
def can_use_qt():
59
try:
610
import sip
711
from PyQt5 import QtCore
812
from PyQt5 import QtWidgets
913
from PyQt5 import QtGui
10-
except ImportError:
14+
except ModuleNotFoundError:
1115
return False
1216
return True
1317

@@ -112,7 +116,7 @@ def is_dark_mode():
112116
def get_main_window():
113117
try:
114118
from PyQt5 import QtWidgets
115-
except ImportError:
119+
except ModuleNotFoundError:
116120
return None
117121

118122
widget = QtWidgets.QApplication.activeWindow()
@@ -143,7 +147,7 @@ def _is_dark_mode(bgcolor, threshold=128):
143147
def is_dark_mode_with_main():
144148
try:
145149
from PyQt5 import QtWidgets
146-
except ImportError:
150+
except ModuleNotFoundError:
147151
return False
148152

149153
widget = dark_mode_checker_t.get_main_window()
@@ -165,7 +169,7 @@ def get_bgcolor(x=0, y=0, w=None):
165169
from PyQt5 import QtCore
166170
from PyQt5 import QtWidgets
167171
from PyQt5 import QtGui
168-
except ImportError:
172+
except ModuleNotFoundError:
169173
return bgcolor
170174

171175
if str(w).startswith("<Swig Object of type 'TWidget *' at") and str(type(w)) in ["<class 'SwigPyObject'>", "<type 'SwigPyObject'>"]: # type: for py2, class: for py3

0 commit comments

Comments
 (0)