diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 34f3b72..1b4d55b 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -484,8 +484,8 @@ class IPythonInputSplitter(InputSplitter): leading_indent(), classic_prompt(), ipy_prompt(), - strip_encoding_cookie(), cellmagic(end_on_blank_line=line_input_checker), + strip_encoding_cookie(), ] self.assemble_logical_lines = assemble_logical_lines() diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index c657d7f..8ee7ba1 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -496,7 +496,7 @@ class IPythonInputTestCase(InputSplitterTestCase): if __name__ == '__main__': # A simple demo for interactive experimentation. This code will not get # picked up by any test suite. - from IPython.core.inputsplitter import InputSplitter, IPythonInputSplitter + from IPython.core.inputsplitter import IPythonInputSplitter # configure here the syntax to use, prompt and whether to autoindent #isp, start_prompt = InputSplitter(), '>>> ' @@ -592,6 +592,16 @@ class CellModeCellMagics(CellMagicsCommon, unittest.TestCase): sp.push('\n') # This should accept a blank line and carry on until the cell is reset nt.assert_true(sp.push_accepts_more()) #3 + + def test_no_strip_coding(self): + src = '\n'.join([ + '%%writefile foo.py', + '# coding: utf-8', + 'print(u"üñîçø∂é")', + ]) + out = self.sp.transform_cell(src) + nt.assert_in('# coding: utf-8', out) + class LineModeCellMagics(CellMagicsCommon, unittest.TestCase): sp = isp.IPythonInputSplitter(line_input_checker=True)