##// END OF EJS Templates
Merge pull request #9778 from takluyver/i9768...
Matthias Bussonnier -
r22732:0845fa68 merge
parent child Browse files
Show More
@@ -325,14 +325,36 b' class TerminalInteractiveShell(InteractiveShell):'
325 pre_run=self.pre_prompt, reset_current_buffer=True)
325 pre_run=self.pre_prompt, reset_current_buffer=True)
326 return document.text
326 return document.text
327
327
328 def enable_win_unicode_console(self):
329 import win_unicode_console
330
331 if PY3:
332 win_unicode_console.enable()
333 else:
334 # https://github.com/ipython/ipython/issues/9768
335 from win_unicode_console.streams import (TextStreamWrapper,
336 stdout_text_transcoded, stderr_text_transcoded)
337
338 class LenientStrStreamWrapper(TextStreamWrapper):
339 def write(self, s):
340 if isinstance(s, bytes):
341 s = s.decode(self.encoding, 'replace')
342
343 self.base.write(s)
344
345 stdout_text_str = LenientStrStreamWrapper(stdout_text_transcoded)
346 stderr_text_str = LenientStrStreamWrapper(stderr_text_transcoded)
347
348 win_unicode_console.enable(stdout=stdout_text_str,
349 stderr=stderr_text_str)
350
328 def init_io(self):
351 def init_io(self):
329 if sys.platform not in {'win32', 'cli'}:
352 if sys.platform not in {'win32', 'cli'}:
330 return
353 return
331
354
332 import win_unicode_console
355 self.enable_win_unicode_console()
333 import colorama
334
356
335 win_unicode_console.enable()
357 import colorama
336 colorama.init()
358 colorama.init()
337
359
338 # For some reason we make these wrappers around stdout/stderr.
360 # For some reason we make these wrappers around stdout/stderr.
General Comments 0
You need to be logged in to leave comments. Login now