##// END OF EJS Templates
Fix various problems highlighted by the test suite.
Thomas Kluyver -
Show More
@@ -2454,7 +2454,7 b' class InteractiveShell(SingletonConfigurable, Magic):'
2454 2454 # Skip our own frame in searching for locals:
2455 2455 sys._getframe(depth+1).f_locals # locals
2456 2456 )
2457 return str(res).decode(res.codec)
2457 return py3compat.str_to_unicode(str(res), res.codec)
2458 2458
2459 2459 def mktempfile(self, data=None, prefix='ipython_edit_'):
2460 2460 """Make a new tempfile and return its filename.
@@ -23,12 +23,12 b' from __future__ import print_function'
23 23 import __builtin__ as builtin_mod
24 24 import os
25 25 import sys
26 from types import MethodType
27 26
28 27 # our own
29 28 from . import tools
30 29
31 30 from IPython.utils import io
31 from IPython.utils import py3compat
32 32 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
33 33
34 34 #-----------------------------------------------------------------------------
@@ -204,11 +204,10 b' def start_ipython():'
204 204 # Modify the IPython system call with one that uses getoutput, so that we
205 205 # can capture subcommands and print them to Python's stdout, otherwise the
206 206 # doctest machinery would miss them.
207 shell.system = MethodType(xsys, shell, TerminalInteractiveShell)
207 shell.system = py3compat.MethodType(xsys, shell)
208 208
209 209
210 shell._showtraceback = MethodType(_showtraceback, shell,
211 TerminalInteractiveShell)
210 shell._showtraceback = py3compat.MethodType(_showtraceback, shell)
212 211
213 212 # IPython is ready, now clean up some global state...
214 213
@@ -27,6 +27,7 b' else:'
27 27 from ._process_posix import _find_cmd, system, getoutput
28 28
29 29 from ._process_common import getoutputerror
30 from IPython.utils import py3compat
30 31
31 32 #-----------------------------------------------------------------------------
32 33 # Code
@@ -115,7 +116,7 b' def arg_split(s, posix=False):'
115 116 # At least encoding the input when it's unicode seems to help, but there
116 117 # may be more problems lurking. Apparently this is fixed in python3.
117 118 is_unicode = False
118 if isinstance(s, unicode):
119 if (not py3compat.PY3) and isinstance(s, unicode):
119 120 is_unicode = True
120 121 s = s.encode('utf-8')
121 122 lex = shlex.shlex(s, posix=posix)
@@ -1,6 +1,7 b''
1 1 # coding: utf-8
2 2 """Compatibility tricks for Python 3. Mainly to do with unicode."""
3 3 import sys
4 import types
4 5
5 6 orig_open = open
6 7
@@ -43,6 +44,8 b' if sys.version_info[0] >= 3:'
43 44 return s.isidentifier()
44 45
45 46 open = orig_open
47
48 MethodType = types.MethodType
46 49
47 50 else:
48 51 PY3 = False
@@ -83,6 +86,9 b' else:'
83 86
84 87 def __exit__(self, etype, value, traceback):
85 88 self.f.close()
89
90 def MethodType(func, instance):
91 return types.MethodType(func, instance, type(instance))
86 92
87 93 def execfile(fname, glob, loc=None):
88 94 loc = loc if (loc is not None) else glob
General Comments 0
You need to be logged in to leave comments. Login now