Ticket #12927: trac_12927

File trac_12927, 2.0 KB (added by itaibn, 9 years ago)

A patch to fix this bug

Line 
1# HG changeset patch
2# User Itai Bar-Natan <itaibn3141@gmail.com>
3# Date 1352069236 18000
4# Node ID 11a56f0a66142824c461ef116e18a8a757fe628d
5# Parent  d06cf4b2215d37d3a87a58f65ac53234502dd471
6[mq]: trac_12927
7
8diff --git a/sage/misc/log.py b/sage/misc/log.py
9--- a/sage/misc/log.py
10+++ b/sage/misc/log.py
11@@ -130,26 +130,6 @@
12         self._stopped = False
13 
14     def _update(self):
15-        """
16-        There is an off-by-one issue with IPython's input and output
17-        history; ``__IPYTHON__.input_hist_raw`` is a *list* containing
18-        the un-preparsed Sage commands. However,
19-        ``__IPYTHON__.output_hist`` is a dictionary whose keys are
20-        integers and whose values are outputs.  This is good because
21-        not every input has an output.
22-
23-        **BUT**, the output from::
24-       
25-            __IPYTHON__.input_hist_raw[n]
26-
27-        is stored in::
28-
29-            __IPYTHON__.output_hist[n+1] !
30-
31-        This is annoying and it may be a bug. Right now the loggers
32-        correct for this, but if modifying or extending this code,
33-        consider yourself warned.
34-        """       
35         if self._stopped:
36             return
37         # see note at end of this function for info about output and
38@@ -160,7 +140,7 @@
39         K = O.keys()
40         while self._n < max(len(I), max(K + [-1])):
41             n = self._n
42-            followed_by_output = (n+1 in K)
43+            followed_by_output = (n in K)
44             if n < len(I):
45                 L = I[n]
46             else:
47@@ -170,9 +150,8 @@
48                 self._write(self._get_input(n, followed_by_output))
49                 self._input_text += L
50             #m = n + offset
51-            m = n
52-            if m+1 in K:
53-                self._write(self._get_output(m+1))
54+            if n in K:
55+                self._write(self._get_output(n))
56                 # what does the following line do? Nothing is done with
57                 # this s. Commenting out for now.
58                 #s = '# ' + '\n# '.join(str(O[m]).split('\n')) + '\n\n'