Opened 9 years ago
Closed 7 years ago
#15271 closed defect (wontfix)
pretty_print_default fails in a terminal session
Reported by: | iandrus | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | user interface | Keywords: | |
Cc: | vbraun, ppurka, novoselt | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Calling pretty_print_default in a terminal fails:
┌────────────────────────────────────────────────────────────────────┐ │ Sage Version 5.12, Release Date: 2013-10-07 │ │ Type "notebook()" for the browser-based notebook interface. │ │ Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ sage: pretty_print_default(True) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-1-b70acc55a8d2> in <module>() ----> 1 pretty_print_default(True) /Users/ivanandres/SageStuff/sage-5.12/local/lib/python2.7/site-packages/sage/misc/latex.pyc in pretty_print_default(enable) 2463 """ 2464 import sys -> 2465 sys.displayhook.set_display('typeset' if enable else 'simple') 2466 2467 AttributeError: 'DisplayHook' object has no attribute 'set_display' sage:
Perhaps calling pretty_print_default doesn't make much sense in the terminal, but it's used in the emacs interface to be able to display typeset output.
I think doctests pass because the doctesting framework sets sys.displayhook to something else, namely sage.misc.displayhook.DisplayHook(sys.displayhook)
. I think the regression was introduced in #15168, and so I have cc'ed the people involved there in case they want to weigh in on how this should be fixed.
Change History (18)
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
Correct, the terminal uses IPython's machinery instead of sys.displayhook
. The doctests and the notebook run commands in non-ipython sessions, so our displayhook is used. IMHO the best way to switch IPython's behavior is with the %display
magic, that is,
sage: %display typeset sage: 1+1 <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}2</script></html>
I see that we don't actually doctest that, this ought to be added to sage/misc/sage_extension.py
comment:3 Changed 9 years ago by
If we want to fix this function, can this be made to call whatever the magic %display typeset
runs?
Maybe run the current code inside a try: except:
construct?
comment:4 Changed 9 years ago by
We can, but imho we should just remove pretty_print_default
.
comment:5 Changed 9 years ago by
Let's use this ticket for removing the function from the global namespace.
comment:6 follow-up: ↓ 7 Changed 9 years ago by
@iandrus - Would the emacs interface work if you set sys.displayhook = sage.misc.displayhook.DisplayHook
from emacs?
comment:7 in reply to: ↑ 6 ; follow-ups: ↓ 8 ↓ 9 Changed 9 years ago by
Replying to ppurka:
@iandrus - Would the emacs interface work if you set
sys.displayhook = sage.misc.displayhook.DisplayHook
from emacs?
Yes that works. Just to be clear, sage.misc.displayhook.DisplayHook
only exists in 5.12 (and later), right?
comment:8 in reply to: ↑ 7 Changed 9 years ago by
Replying to iandrus:
Replying to ppurka:
@iandrus - Would the emacs interface work if you set
sys.displayhook = sage.misc.displayhook.DisplayHook
from emacs?Yes that works. Just to be clear,
sage.misc.displayhook.DisplayHook
only exists in 5.12 (and later), right?
No. That exists from earlier, probably sage-5.11 (#12719).
comment:9 in reply to: ↑ 7 Changed 9 years ago by
Replying to iandrus:
Replying to ppurka:
@iandrus - Would the emacs interface work if you set
sys.displayhook = sage.misc.displayhook.DisplayHook
from emacs?Yes that works. Just to be clear,
sage.misc.displayhook.DisplayHook
only exists in 5.12 (and later), right?
I spoke too soon. Using sage.misc.displayhook.DisplayHook
makes plots not appear (in DOCTEST_MODE so they can be viewed inline as well). I haven't had a change to debug into it yet.
comment:10 Changed 9 years ago by
No graphics is shown in DOCTEST_MODE
, this is the expected behavior.
Whats wrong with %display typeset
?
comment:11 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:12 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:13 follow-up: ↓ 15 Changed 8 years ago by
Sage mode now uses %display typeset
, so I no longer care about this--we can just remove pretty_print_default
.
comment:14 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:15 in reply to: ↑ 13 Changed 7 years ago by
Sage mode now uses
%display typeset
, so I no longer care about this--we can just removepretty_print_default
.
At least from the command line. Possibly also pretty_print
?
However, this is needed in all_notebook.py, so don't just remove it completely!
comment:16 Changed 7 years ago by
- Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
- Status changed from new to needs_review
pretty_print_default seems to no longer be in the global namespace in a terminal session, so I move we close this as won't fix.
comment:17 Changed 7 years ago by
- Status changed from needs_review to positive_review
comment:18 Changed 7 years ago by
- Resolution set to wontfix
- Status changed from positive_review to closed
As commented in the function, this should probably be removed from the global namespace. It is really not useful in the terminal.