Skip to content

Commit 0ba0668

Browse files
committed
BF: guard against broken PyQt import
We may have picked up a broken PyQt that correctly imported, for example if we have imported a Python 3.3 PyQt from Python 3.2; check we do have the attribute we need for getting PyQt versions.
1 parent c001797 commit 0ba0668

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

setupext.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,14 +1653,16 @@ def check(self):
16531653
from PyQt4 import pyqtconfig
16541654
except ImportError:
16551655
raise CheckFailed("PyQt4 not found")
1656-
else:
1657-
1658-
BackendAgg.force = True
1659-
1660-
return ("Qt: %s, PyQt4: %s" %
1661-
(self.convert_qt_version(
1662-
pyqtconfig.Configuration().qt_version),
1663-
pyqtconfig.Configuration().pyqt_version_str))
1656+
# Import may still be broken for our python
1657+
try:
1658+
qtconfig = pyqtconfig.Configuration()
1659+
except AttributeError:
1660+
raise CheckFailed('PyQt4 not correctly imported')
1661+
BackendAgg.force = True
1662+
return ("Qt: %s, PyQt4: %s" %
1663+
(self.convert_qt_version(
1664+
qtconfig.qt_version),
1665+
qtconfig.pyqt_version_str))
16641666

16651667

16661668
class BackendPySide(OptionalBackendPackage):

0 commit comments

Comments
 (0)