Skip to content
This repository

ipython qtconsole (v0.11): setting "c.IPythonWidget.in_prompt = '>>> ' crashes #649

Closed
phn opened this Issue July 31, 2011 · 2 comments

3 participants

Prasanth Min RK Thomas Kluyver
Prasanth
phn commented July 31, 2011

In profile_default/ipython_qtconsole_config.py the following causes iPython to crash

  # c.IPythonWidget.in_prompt = 'In [<span class="in-prompt-number">%i</span>]: '
  c.IPythonWidget.in_prompt = ">>> "

The Crash_report_ipython.txt file contents is given below:


IPython post-mortem report

{'commit_hash': '',
'commit_source': '(none found)',
'ipython_path': '/home/phn/lib/pyvirtualenv/astro_stsci/lib/python2.6/site-packages/IPython',
'ipython_version': '0.11',
'os_name': 'posix',
'platform': 'Linux-2.6.38-10-generic-pae-i686-with-Ubuntu-11.04-natty',
'sys_executable': '/home/phn/lib/pyvirtualenv/astro_stsci/bin/python',
'sys_platform': 'linux2',
'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \n[GCC 4.4.5]'}



Crash traceback:


TypeError Python 2.6.6: /home/phn/lib/pyvirtualenv/astro_stsci/bin/python
Mon Aug 1 11:28:27 2011
A problem occured executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/home/phn/lib/pyvirtualenv/astro_stsci/lib/python2.6/site-packages/IPython/frontend/qt/base_frontend_mixin.pyc in dispatch(self=, msg={'buffers': [], 'content': {'execution_count': 0, 'payload': [], 'status': 'ok', 'user_expressions': {}, 'user_variables': {}}, 'header': {'date': datetime.datetime(2011, 8, 1, 11, 28, 27, 269158), 'msg_id': '4accc4c2-a340-4606-be65-6a30e55c830a', 'msg_type': 'execute_reply', 'session': '1f477c57-a79f-413b-adc0-2b102267c1e6', 'username': 'kernel'}, 'msg_type': 'execute_reply', 'parent_header': {'date': datetime.datetime(2011, 8, 1, 11, 28, 27, 138046), 'msg_id': 'fd17c9e1-738a-459a-b99f-ef7bc54ddab7', 'msg_type': 'execute_request', 'session': '460d5ec9-7ca9-4d22-a1f5-c54aeff335df', 'username': 'phn'}})
87 """ Called when the KernelManager channels have stopped listening or
88 when a listening KernelManager is removed from the frontend.
89 """
90
91 #---------------------------------------------------------------------------
92 # 'BaseFrontendMixin' protected interface
93 #---------------------------------------------------------------------------
94
95 def _dispatch(self, msg):
96 """ Calls the frontend handler associated with the message type of the
97 given message.
98 """
99 msg_type = msg['msg_type']
100 handler = getattr(self, '_handle
' + msg_type, None)
101 if handler:
--> 102 handler(msg)
103
104 def _is_from_this_session(self, msg):
105 """ Returns whether a reply from the kernel originated from a request
106 from this frontend.
107 """
108 session = self._kernel_manager.session.session
109 return msg['parent_header']['session'] == session

/home/phn/lib/pyvirtualenv/astro_stsci/lib/python2.6/site-packages/IPython/frontend/qt/console/ipython_widget.pyc in _handle_execute_reply(self=, msg={'buffers': [], 'content': {'execution_count': 0, 'payload': [], 'status': 'ok', 'user_expressions': {}, 'user_variables': {}}, 'header': {'date': datetime.datetime(2011, 8, 1, 11, 28, 27, 269158), 'msg_id': '4accc4c2-a340-4606-be65-6a30e55c830a', 'msg_type': 'execute_reply', 'session': '1f477c57-a79f-413b-adc0-2b102267c1e6', 'username': 'kernel'}, 'msg_type': 'execute_reply', 'parent_header': {'date': datetime.datetime(2011, 8, 1, 11, 28, 27, 138046), 'msg_id': 'fd17c9e1-738a-459a-b99f-ef7bc54ddab7', 'msg_type': 'execute_request', 'session': '460d5ec9-7ca9-4d22-a1f5-c54aeff335df', 'username': 'phn'}})
155 chop_length = sum(map(len, parts[:sep_count])) + sep_count
156 matches = [ match[chop_length:] for match in matches ]
157 offset -= chop_length
158
159 # Move the cursor to the start of the match and complete.
160 cursor.movePosition(QtGui.QTextCursor.Left, n=offset)
161 self._complete_with_items(cursor, matches)
162
163 def _handle_execute_reply(self, msg):
164 """ Reimplemented to support prompt requests.
165 """
166 info = self._request_info.get('execute')
167 if info and info.id == msg['parent_header']['msg_id']:
168 if info.kind == 'prompt':
169 number = msg['content']['execution_count'] + 1
--> 170 self._show_interpreter_prompt(number)
171 else:
172 super(IPythonWidget, self)._handle_execute_reply(msg)
173
174 def _handle_history_reply(self, msg):
175 """ Implemented to handle history tail replies, which are only supported
176 by the IPython kernel.
177 """
178 history_items = msg['content']['history']
179 items = [ line.rstrip() for _, _, line in history_items ]
180 self._set_history(items)
181
182 def _handle_pyout(self, msg):
183 """ Reimplemented for IPython-style "display hook".
184 """
185 if not self._hidden and self._is_from_this_session(msg):

/home/phn/lib/pyvirtualenv/astro_stsci/lib/python2.6/site-packages/IPython/frontend/qt/console/ipython_widget.pyc in _show_interpreter_prompt(self=, number=1)
316 return True
317

318 def _show_interpreter_prompt(self, number=None):
319 """ Reimplemented for IPython-style prompts.
320 """
321 # If a number was not specified, make a prompt number request.
322 if number is None:
323 msg_id = self.kernel_manager.shell_channel.execute('', silent=True)
324 info = self._ExecutionRequest(msg_id, 'prompt')
325 self._request_info['execute'] = info
326 return
327
328 # Show a new prompt and save information about it so that it can be
329 # updated later if the prompt number turns out to be wrong.
330 self._prompt_sep = self.input_sep
--> 331 self._show_prompt(self._make_in_prompt(number), html=True)
332 block = self._control.document().lastBlock()
333 length = len(self._prompt)
334 self._previous_prompt_obj = self._PromptBlock(block, length, number)
335
336 # Update continuation prompt to reflect (possibly) new prompt length.
337 self._set_continuation_prompt(
338 self._make_continuation_prompt(self._prompt), html=True)
339
340 def _show_interpreter_prompt_for_reply(self, msg):
341 """ Reimplemented for IPython-style prompts.
342 """
343 # Update the old prompt number if necessary.
344 content = msg['content']
345 previous_prompt_number = content['execution_count']
346 if self._previous_prompt_obj and \

/home/phn/lib/pyvirtualenv/astro_stsci/lib/python2.6/site-packages/IPython/frontend/qt/console/ipython_widget.pyc in _make_in_prompt(self=, number=1)
428 command = self.editor.format(filename=filename)
429 else:
430 command += ' ' + filename
431 except KeyError:
432 self._append_plain_text('Invalid editor command.\n')
433 else:
434 try:
435 Popen(command, shell=True)
436 except OSError:
437 msg = 'Opening editor with command "%s" failed.\n'
438 self._append_plain_text(msg % command)
439
440 def _make_in_prompt(self, number):
441 """ Given a prompt number, returns an HTML In prompt.
442 """
--> 443 body = self.in_prompt % number
444 return '%s' % body
445
446 def _make_continuation_prompt(self, prompt):
447 """ Given a plain text version of an In prompt, returns an HTML
448 continuation prompt.
449 """
450 end_chars = '...: '
451 space_count = len(prompt.lstrip('\n')) - len(end_chars)
452 body = ' ' * space_count + end_chars
453 return '%s' % body
454

455 def _make_out_prompt(self, number):
456 """ Given a prompt number, returns an HTML Out prompt.
457 """
458 body = self.out_prompt % number

TypeError: not all arguments converted during string formatting


History of session input:

Thomas Kluyver
Collaborator

N.B. Prompt generation is being refactored for 0.12 - see PR #507.

Min RK
Owner

closed by 9843479

Min RK minrk closed this August 04, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.