Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Catch ValueError when trying to set sip API #152

Merged
merged 3 commits into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ci/test-pyside2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
export PATH="$HOME/miniconda/bin:$PATH"
source activate test

# Download PySide2 wheel
wget -q http://download.qt.io/snapshots/ci/pyside/5.11/latest/pyside2/PySide2-5.11.0a1-5.11.0-cp27-cp27mu-linux_x86_64.whl -O PySide2-5.11.0a1-5.11.0-cp27-cp27mu-linux_x86_64.whl
wget -q http://download.qt.io/snapshots/ci/pyside/5.11/latest/pyside2/PySide2-5.11.0a1-5.11.0-cp36-cp36m-linux_x86_64.whl -O PySide2-5.11.0a1-5.11.0-cp36-cp36m-linux_x86_64.whl
# Download PySide2 wheels
export URL="download.qt.io/snapshots/ci/pyside/5.11/latest/pyside2/"
wget -q -r --no-parent -A 'PySide2-*-linux_x86_64.whl' http://${URL}

# We use container 3 to test with pip
if [ "$CIRCLE_NODE_INDEX" = "0" ]; then
conda remove -q qt pyqt
pip install PySide2-5.11.0a1-5.11.0-cp27-cp27mu-linux_x86_64.whl
pip install ./${URL}/PySide2-*-cp27-cp27mu-linux_x86_64.whl
elif [ "$CIRCLE_NODE_INDEX" = "3" ]; then
pip uninstall -q -y pyqt5 sip
pip install PySide2-5.11.0a1-5.11.0-cp36-cp36m-linux_x86_64.whl
pip install ./${URL}/PySide2-*-cp36-cp36m-linux_x86_64.whl
else
exit 0
fi
Expand Down
31 changes: 17 additions & 14 deletions qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@
# Version of QtPy
from ._version import __version__


class PythonQtError(Exception):
"""Error raise if no bindings could be selected"""
pass


class PythonQtWarning(Warning):
"""Warning if some features are not implemented in a binding."""
pass


# Qt API environment variable name
QT_API = 'QT_API'

Expand Down Expand Up @@ -99,14 +110,6 @@
PYQT4 = PYSIDE = PYSIDE2 = False


class PythonQtError(Exception):
"""Error raise if no bindings could be selected"""
pass

class PythonQtWarning(Warning):
"""Warning if some features are not implemented in a binding."""
pass

if 'PyQt5' in sys.modules:
API = 'pyqt5'
elif 'PySide2' in sys.modules:
Expand Down Expand Up @@ -147,7 +150,7 @@ class PythonQtWarning(Warning):
sip.setapi('QTextStream', 2)
sip.setapi('QTime', 2)
sip.setapi('QUrl', 2)
except AttributeError:
except (AttributeError, ValueError):
# PyQt < v4.6
pass
from PyQt4.Qt import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
Expand Down Expand Up @@ -181,8 +184,8 @@ class PythonQtWarning(Warning):
'pyside': 'PySide', 'pyside2':'PySide2'}[API]

if PYQT4:
import sip
try:
API_NAME += (" (API v{0})".format(sip.getapi('QString')))
except AttributeError:
pass
import sip
try:
API_NAME += (" (API v{0})".format(sip.getapi('QString')))
except AttributeError:
pass