Skip to content

Commit

Permalink
Trac #9683: pretty_print clobbers _ (history)
Browse files Browse the repository at this point in the history
After using `pretty_print`, the first history variable (`_`) no longer
updates.

{{{
----------------------------------------------------------------------
| Sage Version 4.5.1, Release Date: 2010-07-19                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
Loading Sage library. Current Mercurial branch is: combinat
sage: 17
17
sage: _
17
sage: 23
23
sage: _
23
sage: pretty_print(17)
<html><span
class="math">\newcommand{\Bold}[1]{\mathbf{#1}}17</span></html>
sage: _
17
sage: 23
23
sage: _
17
}}}

The relevant function seems to be `pretty_print` in
`/sage/misc/latex.py`, but I don't know the right way to fix it. The
function and `pretty_print_default` in same file, and the functions
`displayhook` and `install` in `/sage/misc/displayhook.py` may also be
relevant.

URL: http://trac.sagemath.org/9683
Reported by: mguaypaq
Ticket author(s): Mike Hansen
Reviewer(s): Volker Braun
  • Loading branch information
Release Manager authored and vbraun committed Apr 12, 2014
2 parents 3b94c5f + 3cc45a8 commit a143cc0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/sage/misc/latex.py
Expand Up @@ -2419,12 +2419,16 @@ def _show_s(s):
print MathJax().eval(tuple(s), mode='inline',
combine_all=True)

import __builtin__
in_ipython = hasattr(__builtin__, 'get_ipython')
s = []
for object in args:
if object is None:
continue
import __builtin__
__builtin__._=object
if in_ipython:
get_ipython().displayhook.update_user_ns(object)
else:
__builtin__._ = object

from sage.plot.plot import Graphics
from sage.plot.plot3d.base import Graphics3d
Expand Down

0 comments on commit a143cc0

Please sign in to comment.