From b43e05413eca096f4d4879e644dcad03bd11e8ed 2011-11-29 21:08:16
From: Matthias BUSSONNIER <bussonniermatthias@gmail.com>
Date: 2011-11-29 21:08:16
Subject: [PATCH] fix to minrk suggestion

---

diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py
index 508cbed..9e7bde0 100644
--- a/IPython/frontend/qt/console/frontend_widget.py
+++ b/IPython/frontend/qt/console/frontend_widget.py
@@ -374,10 +374,8 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):
         """ Handles replies for code execution.
         """
         self.log.debug("execute: %s", msg.get('content', ''))
-        info_list = self._request_info.get('execute')
         msg_id = msg['parent_header']['msg_id']
-        if msg_id in info_list:
-            info = info_list[msg_id]
+        info = self._request_info['execute'].get(msg_id)
         # unset reading flag, because if execute finished, raw_input can't
         # still be pending.
         self._reading = False
@@ -403,7 +401,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):
 
             self._show_interpreter_prompt_for_reply(msg)
             self.executed.emit(msg)
-            info_list.pop(msg_id)
+            self._request_info['execute'].pop(msg_id)
         elif info and info.kind == 'silent_exec_callback' and not self._hidden:
             self._handle_exec_callback(msg)
         else:
diff --git a/IPython/frontend/qt/console/history_console_widget.py b/IPython/frontend/qt/console/history_console_widget.py
index d095792..5c7657d 100644
--- a/IPython/frontend/qt/console/history_console_widget.py
+++ b/IPython/frontend/qt/console/history_console_widget.py
@@ -216,15 +216,13 @@ class HistoryConsoleWidget(ConsoleWidget):
     def _handle_execute_reply(self, msg):
         """ Handles replies for code execution, here only session history length
         """
-        info_list = self._request_info.get('execute')
         msg_id = msg['parent_header']['msg_id']
-        if msg_id in info_list:
-            info = info_list.pop(msg_id)
-            if info.kind == 'save_magic' and not self._hidden:
-                content = msg['content']
-                status = content['status']
-                if status == 'ok':
-                    self._max_session_history=(int(content['user_expressions']['hlen']))
+        info = self._request_info.get['execute'].pop(msg_id,None)
+        if info and info.kind == 'save_magic' and not self._hidden:
+            content = msg['content']
+            status = content['status']
+            if status == 'ok':
+                self._max_session_history=(int(content['user_expressions']['hlen']))
 
     def save_magic(self):
         # update the session history length
diff --git a/IPython/frontend/qt/console/ipython_widget.py b/IPython/frontend/qt/console/ipython_widget.py
index 6913f2d..5147139 100644
--- a/IPython/frontend/qt/console/ipython_widget.py
+++ b/IPython/frontend/qt/console/ipython_widget.py
@@ -165,16 +165,14 @@ class IPythonWidget(FrontendWidget):
     def _handle_execute_reply(self, msg):
         """ Reimplemented to support prompt requests.
         """
-        info_list = self._request_info.get('execute')
-        msg_id = msg['parent_header']['msg_id']
-        if msg_id in info_list:
-            info = info_list[msg_id]
-            if info.kind == 'prompt':
-                number = msg['content']['execution_count'] + 1
-                self._show_interpreter_prompt(number)
-                info_list.pop(msg_id)
-            else:
-                super(IPythonWidget, self)._handle_execute_reply(msg)
+        msg_id = msg['parent_header'].get('msg_id')
+        info = self._request_info['execute'].get(msg_id)
+        if info and info.kind == 'prompt':
+           number = msg['content']['execution_count'] + 1
+           self._show_interpreter_prompt(number)
+           self._request_info['execute'].pop(msg_id)
+        else:
+           super(IPythonWidget, self)._handle_execute_reply(msg)
 
     def _handle_history_reply(self, msg):
         """ Implemented to handle history tail replies, which are only supported