Skip to content
This repository

don't assume cursor.selectedText() is a string #725

Merged
merged 1 commit into from over 2 years ago

5 participants

Min RK Fernando Perez Evan Patterson Rajeev Jain Thomas Kluyver
Min RK
Owner

Apparently in some cases cursor.selectedText() can return None instead of an empty
string (Scientific Linux 6.0 being only reported case). Relax logic using this method,
so string methods are only called when the string is not empty.

Should fix #724

Fernando Perez
Owner

+1, correct logic, thanks for fixing this. Merge away.

Since your message doesn't say 'closes gh-724' you may need to do it manually, I don't know if gh will identify 'fix #724' as well.

Min RK
Owner

the actual commit message does have the 'closes' text. The commit parser is pretty greedy, though - I have had it auto-close Issues I only mentioned.

Fernando Perez
Owner

Ah, got it. Good to know, thanks.

Evan Patterson
Collaborator

It doesn't seem appropriate to merge this. Please see the discussion in #724, in which the user reports further problems.

Min RK
Owner

Yes, either we need to place a bound on our PyQt version dependency, or fix every string check to allow for None.

Fernando Perez
Owner
Min RK
Owner

Fair enough, but what version? Do we just guess that 4.7.0 resolves the issue? I see no evidence of this change in the pyqt docs, and I'm certainly not going to build a bunch of PyQt versions to find out.

Should we make the PySide import version check as well, since early dev versions are known to not work?

Fernando Perez
Owner
Min RK
Owner

There's also the hilarious fact that I have no idea how to find out the PyQt version from Python...

Evan Patterson
Collaborator

@fperez I don't know which versions of PyQt have this bug, sorry. It may be worth posting to their mailing list. For PySide, I think that versions 1.0.3+ work with IPython.

@minrk It's not very well advertised, but this works:

from PyQt4 import QtCore
QtCore.QT_VERSION, QtCore.QT_VERSION_STR  # Qt version info
QtCore.PYQT_VERSION, Qtcore.PYQT_VERSION_STR # Binding version info
Min RK version check Qt bindings in external.qt
require PySide >= 1.0.3 or PyQt4 >= 4.7

closes gh-724
be3e7ed
Min RK
Owner

Thanks, @epatters, it would have taken me a long time to find that.

I just redid this branch, so that it only adds version checks to external.qt, so the frontend won't try to start with PyQt < 4.7 or PySide < 1.0.3.

Evan Patterson
Collaborator

Well, this looks good to me. Thanks, Min.

Min RK minrk merged commit 6cf495c into from
Min RK minrk closed this
Brian E. Granger ellisonbg referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Thomas Kluyver

@rajeeja: Hi, welcome to IPython. The best thing for this sort of problem is to join the ipython-user mailing list and ask for help there - that way more people will see your question. http://mail.scipy.org/mailman/listinfo/ipython-user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 24, 2011
Min RK version check Qt bindings in external.qt
require PySide >= 1.0.3 or PyQt4 >= 4.7

closes gh-724
be3e7ed
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 13 additions and 1 deletion. Show diff stats Hide diff stats

  1. 14  IPython/external/qt.py
14  IPython/external/qt.py
@@ -25,14 +25,21 @@ def prepare_pyqt4():
25 25
 if QT_API is None:
26 26
     try:
27 27
         import PySide
  28
+        if PySide.__version__ < '1.0.3':
  29
+            # old PySide, fallback on PyQt
  30
+            raise ImportError
28 31
         QT_API = QT_API_PYSIDE
29 32
     except ImportError:
30 33
         try:
31 34
             prepare_pyqt4()
32 35
             import PyQt4
  36
+            from PyQt4 import QtCore
  37
+            if QtCore.PYQT_VERSION_STR < '4.7':
  38
+                # PyQt 4.6 has issues with null strings returning as None
  39
+                raise ImportError
33 40
             QT_API = QT_API_PYQT
34 41
         except ImportError:
35  
-            raise ImportError('Cannot import PySide or PyQt4')
  42
+            raise ImportError('Cannot import PySide >= 1.0.3 or PyQt4 >= 4.7')
36 43
         
37 44
 elif QT_API == QT_API_PYQT:
38 45
     # Note: This must be called *before* PyQt4 is imported.
@@ -41,12 +48,17 @@ def prepare_pyqt4():
41 48
 # Now peform the imports.
42 49
 if QT_API == QT_API_PYQT:
43 50
     from PyQt4 import QtCore, QtGui, QtSvg
  51
+    if QtCore.PYQT_VERSION_STR < '4.7':
  52
+        raise ImportError("IPython requires PyQt4 >= 4.7, found %s"%QtCore.PYQT_VERSION_STR)
44 53
 
45 54
     # Alias PyQt-specific functions for PySide compatibility.
46 55
     QtCore.Signal = QtCore.pyqtSignal
47 56
     QtCore.Slot = QtCore.pyqtSlot
48 57
 
49 58
 elif QT_API == QT_API_PYSIDE:
  59
+    import PySide
  60
+    if PySide.__version__ < '1.0.3':
  61
+        raise ImportError("IPython requires PySide >= 1.0.3, found %s"%PySide.__version__)
50 62
     from PySide import QtCore, QtGui, QtSvg
51 63
 
52 64
 else:
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.