From 75541c19d6deefd6f6372be468813c16b83541fe 2014-05-12 18:26:00 From: Thomas Kluyver Date: 2014-05-12 18:26:00 Subject: [PATCH] Fix writing history with output to a file in Python 2 Closes gh-2412 --- diff --git a/IPython/core/magics/history.py b/IPython/core/magics/history.py index 6dcc768..c21fa2f 100644 --- a/IPython/core/magics/history.py +++ b/IPython/core/magics/history.py @@ -24,6 +24,7 @@ from IPython.core.magic_arguments import (argument, magic_arguments, parse_argstring) from IPython.testing.skipdoctest import skip_doctest from IPython.utils import io +from IPython.utils.py3compat import cast_unicode_py2 #----------------------------------------------------------------------------- # Magics class implementation @@ -213,7 +214,7 @@ class HistoryMagics(Magics): inline = "\n... ".join(inline.splitlines()) + "\n..." print(inline, file=outfile) if get_output and output: - print(output, file=outfile) + print(cast_unicode_py2(output), file=outfile) if close_at_end: outfile.close()