diff --git a/IPython/core/payloadpage.py b/IPython/core/payloadpage.py index 682fd9b..4ac0e38 100644 --- a/IPython/core/payloadpage.py +++ b/IPython/core/payloadpage.py @@ -37,7 +37,6 @@ def page(strng, start=0, screen_lines=0, pager_cmd=None): payload = dict( source='page', data=data, - text=strng, start=start, screen_lines=screen_lines, ) diff --git a/IPython/kernel/adapter.py b/IPython/kernel/adapter.py index 58a2649..3b7f5b0 100644 --- a/IPython/kernel/adapter.py +++ b/IPython/kernel/adapter.py @@ -222,6 +222,14 @@ class V4toV5(Adapter): user_variables = content.pop('user_variables', {}) if user_variables: user_expressions.update(user_variables) + + # Pager payloads became a mime bundle + for payload in content.get('payload', []): + if payload.get('source', None) == 'page' and ('text' in payload): + if 'data' not in payload: + payload['data'] = {} + payload['data']['text/plain'] = payload.pop('text') + return msg def complete_request(self, msg): diff --git a/IPython/kernel/tests/test_adapter.py b/IPython/kernel/tests/test_adapter.py index 8590fd2..c59499c 100644 --- a/IPython/kernel/tests/test_adapter.py +++ b/IPython/kernel/tests/test_adapter.py @@ -86,6 +86,22 @@ class V4toV5TestCase(AdapterTest): self.assertEqual(v5c['user_expressions'], {'a' : 'apple', 'b': 'b'}) self.assertNotIn('user_variables', v5c) self.assertEqual(v5c['code'], v4c['code']) + + def test_execute_reply(self): + msg = self.msg("execute_reply", { + 'status': 'ok', + 'execution_count': 7, + 'user_variables': {'a': 1}, + 'user_expressions': {'a+a': 2}, + 'payload': [{'source':'page', 'text':'blah'}] + }) + v4, v5 = self.adapt(msg) + v5c = v5['content'] + self.assertNotIn('user_variables', v5c) + self.assertEqual(v5c['user_expressions'], {'a': 1, 'a+a': 2}) + self.assertEqual(v5c['payload'], [{'source': 'page', + 'data': {'text/plain': 'blah'}} + ]) def test_complete_request(self): msg = self.msg("complete_request", {