Skip to content

Commit

Permalink
[ipython] Make ipython work for Python 3 as well
Browse files Browse the repository at this point in the history
Account for an ipython3 quirk that makes it require unwrapped stdout/stderr for
the import as well.
  • Loading branch information
Elad Alfassa committed Apr 29, 2014
1 parent a732720 commit c3b8bb3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@
from __future__ import unicode_literals
import willie
import sys
if sys.version_info.major >= 3:
# Backup stderr/stdout wrappers
old_stdout = sys.stdout
old_stderr = sys.stderr

# IPython wants actual stderr and stdout. In Python 2, it only needed that
# when actually starting the console, but in Python 3 it seems to need that
# on import as well
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__

from IPython.frontend.terminal.embed import InteractiveShellEmbed

if sys.version_info.major >= 3:
# Restore stderr/stdout wrappers
sys.stdout = old_stdout
sys.stderr = old_stderr

console = None


Expand Down

0 comments on commit c3b8bb3

Please sign in to comment.