On 5/10/07, Fernando Perez <[EMAIL PROTECTED]> wrote:
> On 5/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > [EMAIL PROTECTED]:~$ sage/sage -python
> > Python 2.5.1 (r251:54863, May 10 2007, 15:24:24)
> > [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import readline
> > >>> readline.__file__
> > '/home/boothby/sage/local/lib/python2.5/lib-dynload/readline.so'
> > >>> dir(readline)
> > ['__doc__', '__file__', '__name__', 'add_history', 'get_begidx', 
> > 'get_completer', 'get_completer_delims', 'get_current_history_length', 
> > 'get_endidx', 'get_history_item', 'get_history_length', 'get_line_buffer', 
> > 'insert_text', 'parse_and_bind', 'read_history_file', 'read_init_file', 
> > 'redisplay', 'remove_history_item', 'replace_history_item', 
> > 'set_completer', 'set_completer_delims', 'set_history_length', 
> > 'set_startup_hook', 'write_history_file']
>
> This is odd.  Try the same thing with your system python so we can
> look for differences.  Somehow it seems the readline in SAGE python is
> missing two things:
>
> clear_history
> set_pre_input_hook
>
> clear_history was added to Python ages ago:
>
> http://osdir.com/ml/python.patches/2003-09/msg00139.html
>
> So I'm a bit at a loss as to what the hell is going on in your box.
> Let's check:
>
> planck[~]> strings /lib/libreadline.so.5 | grep clear_history
> clear_history
>
>
> so we at least know that your base readline DOES have clear_history
> (it would be very odd if it didn't).  Also do the same on both the
> system python readline module and the SAGE one:
>
> planck[~]> strings /usr/lib/python2.5/lib-dynload/readline.so | grep
> clear_history
> clear_history
> clear_history
> clear_history() -> None
>
>
> I'm very puzzled...  Nothing in the Python changelog mentions this
> function having been removed:
>
> http://www.python.org/download/releases/2.5.1/NEWS.txt
>

I just did a fresh build of sage-2.5 on one of my 64-bit linux boxes,
and clear_history is definitely *not* in Python 2.5.1's build of
readline on this system.   The main reason we upgraded to
Python 2.5.1 is to fix some very nasty *Python* bugs in the readline
module, so it is entirely possible that removing this function
did in fact occur with Python 2.5.1, especially since the readline
included in SAGE is totally standard and hasn't changed in a
long time.

Observations:
 (1) As far as I can tell, if one just comments out line 1257
from SAGE_ROOT/local/lib/python2.5/site-packages/IPython/iplib.py
then everything works fine:

        if self.has_readline:
            #self.readline.clear_history()
            self.readline.read_history_file(self.shell.histfile)

When would this not work?

(2) Why do you have to do clear_history()?  Are you sure that read_history_file
doesn't clear out the history?  The Python docstring is not clear on this point:

read_history_file([filename]) -> Non
    Load a readline history file.
    The default filename is ~/.history.

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to