Skip to content

sage-shell-mode doesn't handle (unicode) strings containing non-ASCII characters #45

@EmmanuelCharpentier

Description

@EmmanuelCharpentier

Noticed in this ask.sagemath question.

I'm currently working in a Python 3-based Sage, where strings are systematically Unicode. This will soon become the default.

In a terminal:

sage: S="à"
sage: show(S)
\newcommand{\Bold}[1]{\mathbf{#1}}\verb|à|

In an emacs buffet, inline-typesettig disabled:

sage: S="à"
sage: show(S)
\newcommand{\Bold}[1]{\mathbf{#1}}\verb|à|

In an emacs buffet, inline-typesettig enabled:

sage: S="à"
sage: show(S)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-0b3d0aeda691> in <module>()
----> 1 show(S)

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/pretty_print.py in show(*args, **kwds)
    256         args[0].show()
    257         return
--> 258     pretty_print(*args, **kwds)

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/pretty_print.py in pretty_print(*args, **kwds)
    227             pass
    228         elif len(args) == 1:
--> 229             dm.display_immediately(*args, **kwds)
    230         else:
    231             SequencePrettyPrinter(*args, **kwds).pretty_print()

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/display_manager.py in display_immediately(self, obj, **rich_repr_kwds)
    836         """
    837         plain_text, rich_output = self._rich_output_formatter(obj, rich_repr_kwds)
--> 838         self._backend.display_immediately(plain_text, rich_output)
    839 
    840 

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/backend_ipython.py in display_immediately(self, plain_text, rich_output)
    302             Example plain text output
    303         """
--> 304         formatdata, metadata = self.displayhook(plain_text, rich_output)
    305         print(formatdata[u'text/plain'])
    306 

/home/charpent/.emacs.d/elpa/sage-shell-mode-20180215.835/emacs_sage_shell_view.py in displayhook(self, plain_text, rich_output)
     55         elif isinstance(rich_output, OutputLatex):
     56             text = "" + plain_text.text.get() + ""
     58             return ({u'text/plain': text}, {})
     59         else:

TypeError: can only concatenate str (not "bytes") to str

This works without error in a Jupyter notebook.

IMHO, this is a bug specific to sage-shell-mode (the last entry in the stack is in its code: .../elpa/sage-shell-mode-20180215.835/emacs_sage_shell_view.py in displayhook(self, plain_text, rich_output))...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions