##// END OF EJS Templates
Merge pull request #2738 from mdboom/pager-encoding...
Bradley M. Froehle -
r8990:66274d0e merge
parent child Browse files
Show More
@@ -29,6 +29,7 b' from __future__ import print_function'
29
29
30 import os
30 import os
31 import re
31 import re
32 import subprocess
32 import sys
33 import sys
33 import tempfile
34 import tempfile
34
35
@@ -41,6 +42,7 b' from IPython.utils.data import chop'
41 from IPython.utils import io
42 from IPython.utils import io
42 from IPython.utils.process import system
43 from IPython.utils.process import system
43 from IPython.utils.terminal import get_terminal_size
44 from IPython.utils.terminal import get_terminal_size
45 from IPython.utils import py3compat
44
46
45
47
46 #-----------------------------------------------------------------------------
48 #-----------------------------------------------------------------------------
@@ -219,9 +221,12 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):'
219 # if I use popen4, things hang. No idea why.
221 # if I use popen4, things hang. No idea why.
220 #pager,shell_out = os.popen4(pager_cmd)
222 #pager,shell_out = os.popen4(pager_cmd)
221 pager = os.popen(pager_cmd,'w')
223 pager = os.popen(pager_cmd, 'w')
222 pager.write(strng)
224 try:
223 pager.close()
225 pager_encoding = pager.encoding or sys.stdout.encoding
224 retval = pager.close() # success returns None
226 pager.write(py3compat.cast_bytes_py2(
227 strng, encoding=pager_encoding))
228 finally:
229 retval = pager.close()
225 except IOError as msg: # broken pipe when user quits
230 except IOError as msg: # broken pipe when user quits
226 if msg.args == (32,'Broken pipe'):
231 if msg.args == (32, 'Broken pipe'):
227 retval = None
232 retval = None
@@ -338,4 +343,3 b" def snip_print(str,width = 75,print_full = 0,header = ''):"
338 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
343 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
339 page(str)
344 page(str)
340 return snip
345 return snip
341
General Comments 0
You need to be logged in to leave comments. Login now