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

Don't try to use "?" to automatically get help in the IPython console #3422

Merged
merged 5 commits into from
Sep 15, 2016
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
12 changes: 5 additions & 7 deletions spyder/widgets/ipythonconsole/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,21 @@ def showEvent(self, event):
"""Reimplement Qt Method"""
self.visibility_changed.emit(True)

def _key_question(self, text, force=False):
""" Action for '?' and '(' """
def _key_paren_left(self, text):
""" Action for '(' """
self.current_prompt_pos = self.parentWidget()._prompt_pos
if self.get_current_line_to_cursor():
last_obj = self.get_last_obj()
if last_obj and not last_obj.isdigit():
self.show_object_info(last_obj, force=force)
self.show_object_info(last_obj)
self.insert_text(text)

def keyPressEvent(self, event):
"""Reimplement Qt Method - Basic keypress event handler"""
event, text, key, ctrl, shift = restore_keyevent(event)
if key == Qt.Key_Question and not self.has_selected_text():
self._key_question(text, force=True)
elif key == Qt.Key_ParenLeft and not self.has_selected_text() \
if key == Qt.Key_ParenLeft and not self.has_selected_text() \
and self.help_enabled:
self._key_question(text)
self._key_paren_left(text)
else:
# Let the parent widget handle the key press event
QTextEdit.keyPressEvent(self, event)
Expand Down
19 changes: 11 additions & 8 deletions spyder/widgets/ipythonconsole/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ def write_to_stdin(self, line):
# ---- Private API (defined by us) -------------------------------
def _post_exec_input(self, line):
"""Commands to be run after writing to stdin"""
pdb_commands = ['next', 'continue', 'step', 'return']
if any([x == line for x in pdb_commands]):
# To open the file where the current pdb frame points to
self.silent_exec_input("!get_ipython().kernel.get_pdb_step()")

# To refresh the Variable Explorer
self.silent_exec_input("!get_ipython().kernel.get_namespace_view()")
self.silent_exec_input("!get_ipython().kernel.get_var_properties()")
if self._reading:
pdb_commands = ['next', 'continue', 'step', 'return']
if any([x == line for x in pdb_commands]):
# To open the file where the current pdb frame points to
self.silent_exec_input("!get_ipython().kernel.get_pdb_step()")

# To refresh the Variable Explorer
self.silent_exec_input(
"!get_ipython().kernel.get_namespace_view()")
self.silent_exec_input(
"!get_ipython().kernel.get_var_properties()")

# ---- Private API (overrode by us) -------------------------------
def _handle_input_request(self, msg):
Expand Down
10 changes: 5 additions & 5 deletions spyder/widgets/ipythonconsole/namespacebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def get_value(self, name):

# Wait until the kernel returns the value
wait_loop = QEventLoop()
self.sig_get_value.connect(wait_loop.quit)
self.sig_got_reply.connect(wait_loop.quit)
self.silent_execute("get_ipython().kernel.get_value('%s')" % name)
wait_loop.exec_()

# Remove loop connection and loop
self.sig_get_value.disconnect(wait_loop.quit)
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None

# Handle exceptions
Expand Down Expand Up @@ -152,8 +152,8 @@ def _handle_data_message(self, msg):
data = deserialize_object(msg['buffers'])[0]
except Exception as msg:
self._kernel_value = None
self._kernel_reply = msg
self.sig_get_value.emit()
self._kernel_reply = repr(msg)
self.sig_got_reply.emit()
return

# We only handle data asked by Spyder
Expand All @@ -162,7 +162,7 @@ def _handle_data_message(self, msg):
if isinstance(value, CannedObject):
value = value.get_object()
self._kernel_value = value
self.sig_get_value.emit()
self.sig_got_reply.emit()

# ---- Private API (overrode by us) ----------------------------
def _handle_execute_reply(self, msg):
Expand Down
6 changes: 4 additions & 2 deletions spyder/widgets/ipythonconsole/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ShellWidget(NamepaceBrowserWidget, HelpWidget, DebuggingWidget):
# For NamepaceBrowserWidget
sig_namespace_view = Signal(object)
sig_var_properties = Signal(object)
sig_get_value = Signal()

# For DebuggingWidget
sig_input_reply = Signal()
Expand Down Expand Up @@ -226,7 +225,10 @@ def handle_exec_method(self, msg):
properties = ast.literal_eval(data['text/plain'])
self.sig_var_properties.emit(properties)
else:
self._kernel_reply = ast.literal_eval(data['text/plain'])
if data is not None:
self._kernel_reply = ast.literal_eval(data['text/plain'])
else:
self._kernel_reply = None
self.sig_got_reply.emit()

# Remove method after being processed
Expand Down