Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
EmmanuelCharpentier opened this issue Sep 29, 2019 · 0 comments

Comments

@EmmanuelCharpentier
Copy link
Collaborator

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))...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant