diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 728467f..7e91912 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -1730,7 +1730,7 @@ class InteractiveShell(Configurable, Magic): args = arg_s.split(' ',1) magic_name = args[0] magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) - + try: magic_args = args[1] except IndexError: @@ -2453,12 +2453,11 @@ class InteractiveShell(Configurable, Magic): The global namespace for expansion is always the user's interactive namespace. """ - - return str(ItplNS(cmd, - self.user_ns, # globals + res = ItplNS(cmd, self.user_ns, # globals # Skip our own frame in searching for locals: sys._getframe(depth+1).f_locals # locals - )) + ) + return str(res).decode(res.codec) def mktempfile(self, data=None, prefix='ipython_edit_'): """Make a new tempfile and return its filename. diff --git a/IPython/utils/text.py b/IPython/utils/text.py index 9ccf2de..e00266c 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -282,6 +282,7 @@ def make_quoted_expr(s): tail = '' tailpadding = '' raw = '' + ucode = 'u' if "\\" in s: raw = 'r' if s.endswith('\\'): @@ -298,7 +299,7 @@ def make_quoted_expr(s): else: # give up, backslash-escaped string will do return '"%s"' % esc_quotes(s) - res = raw + quote + s + tailpadding + quote + tail + res = ucode + raw + quote + s + tailpadding + quote + tail return res