##// END OF EJS Templates
Fix for %hist saving non-ascii history to file....
Thomas Kluyver -
Show More
@@ -15,6 +15,7 b' from __future__ import print_function'
15 # Stdlib imports
15 # Stdlib imports
16 import atexit
16 import atexit
17 import datetime
17 import datetime
18 from io import open as io_open
18 import os
19 import os
19 import re
20 import re
20 try:
21 try:
@@ -808,7 +809,7 b" def magic_history(self, parameter_s = ''):"
808 print('Aborting.')
809 print('Aborting.')
809 return
810 return
810 print("Overwriting file.")
811 print("Overwriting file.")
811 outfile = open(outfname,'w')
812 outfile = io_open(outfname, 'w', encoding='utf-8')
812 close_at_end = True
813 close_at_end = True
813
814
814 print_nums = 'n' in opts
815 print_nums = 'n' in opts
@@ -851,10 +852,10 b" def magic_history(self, parameter_s = ''):"
851 multiline = "\n" in inline
852 multiline = "\n" in inline
852 line_sep = '\n' if multiline else ' '
853 line_sep = '\n' if multiline else ' '
853 if print_nums:
854 if print_nums:
854 print('%s:%s' % (_format_lineno(session, lineno).rjust(width),
855 print(u'%s:%s' % (_format_lineno(session, lineno).rjust(width),
855 line_sep), file=outfile, end='')
856 line_sep), file=outfile, end=u'')
856 if pyprompts:
857 if pyprompts:
857 print(">>> ", end="", file=outfile)
858 print(u">>> ", end=u"", file=outfile)
858 if multiline:
859 if multiline:
859 inline = "\n... ".join(inline.splitlines()) + "\n..."
860 inline = "\n... ".join(inline.splitlines()) + "\n..."
860 print(inline, file=outfile)
861 print(inline, file=outfile)
General Comments 0
You need to be logged in to leave comments. Login now