Skip to content

Commit

Permalink
Merge pull request #3994 from rlaverde/qregularexpression-qt55
Browse files Browse the repository at this point in the history
PR: Use QRegularExpression only for Qt 5.5+
  • Loading branch information
ccordoba12 authored Jan 20, 2017
2 parents f78c8fe + 8807467 commit f60842d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions spyder/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@
from qtpy.QtCore import QPoint, Qt
from qtpy.QtGui import QCursor, QTextCursor, QTextDocument
from qtpy.QtWidgets import QApplication, QToolTip
from qtpy import PYQT5

if PYQT5:
from qtpy.QtCore import QRegularExpression
else:
from qtpy.QtCore import QRegExp
from qtpy import QT_VERSION

# Local imports
from spyder.config.base import _
from spyder.py3compat import is_text_string, to_text_string, u
from spyder.utils import encoding, sourcecode
from spyder.utils import encoding, sourcecode, programs
from spyder.utils.dochelpers import (getargspecfromtext, getobj,
getsignaturefromtext)
from spyder.utils.misc import get_error_match
from spyder.widgets.arraybuilder import NumpyArrayDialog

QT55_VERSION = programs.check_version(QT_VERSION, "5.5", ">=")

if QT55_VERSION:
from qtpy.QtCore import QRegularExpression
else:
from qtpy.QtCore import QRegExp

HISTORY_FILENAMES = []

Expand Down Expand Up @@ -490,7 +491,7 @@ def find_text(self, text, changed=True, forward=True, case=False,
moves += [QTextCursor.End]
if not regexp:
text = re.escape(to_text_string(text))
if PYQT5:
if QT55_VERSION:
pattern = QRegularExpression(r"\b{}\b".format(text) if words else
text)
if case:
Expand Down

0 comments on commit f60842d

Please sign in to comment.