Skip to content

Commit

Permalink
fix QIntValidator allows '+'
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Nov 18, 2022
1 parent dcc4fbb commit c95c9fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions spyder/plugins/editor/widgets/gotoline.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def __init__(self, editor):

ok_button = bbox.button(QDialogButtonBox.Ok)
ok_button.setEnabled(False)
# QIntValidator does not handle '+' sign
# See Spyder PR #20070
self.lineedit.textChanged.connect(
lambda text: ok_button.setEnabled(len(text) > 0))
lambda text: ok_button.setEnabled(len(text) > 0 and text != '+'))

layout = QHBoxLayout()
layout.addLayout(glayout)
Expand All @@ -75,10 +77,14 @@ def __init__(self, editor):
def text_has_changed(self, text):
"""Line edit's text has changed."""
text = str(text)
if text:

# QIntValidator does not handle '+' sign
# See Spyder PR #20070
if text and text != '+':
self.lineno = int(text)
else:
self.lineno = None
self.lineedit.clear()

def get_line_number(self):
"""Return line number."""
Expand Down
8 changes: 7 additions & 1 deletion spyder/plugins/variableexplorer/widgets/importwizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,13 @@ def get_row_sep(self):

def get_skiprows(self):
"""Return number of lines to be skipped"""
return int(to_text_string(self.skiprows_edt.text()))
skip_rows = to_text_string(self.skiprows_edt.text())
# QIntValidator does not handle '+' sign
# See Spyder PR #20070
if skip_rows and skip_rows != '+':
return int(skip_rows)
else:
return 0

def get_comments(self):
"""Return comment string"""
Expand Down

0 comments on commit c95c9fe

Please sign in to comment.