[IPython-dev] Updates to CVS: tab completion and Windows coloring

Gary Bishop gb at cs.unc.edu
Sat Dec 6 16:39:55 EST 2003


Fernando, here are the updates you requested.

On Mon, 01 Dec 2003 14:49:41 -0700 "Fernando Perez" 
<fperez at colorado.edu> wrote:
> Gary:  I'd also like you to help me with a couple of things concerning 
> this code.

> 1.  You made changes to page(), to make it work with 'less' under 
> windows+cygwin.  I want to be sure that users who DON'T have cygwin are 
> still ok.  Is that the case?

The changes below appear to make it work with no pager, with the "more" 
that ships with Windows, and with "less" from Cygwin. With the 
environment variable PAGER unset it will use iPython's pager. With 
PAGER=more, it will use the windows more.com. With PAGER=less it will 
use the cygwin pager. Probably works with others too. I tried this on 
both 2.2 and 2.3.

> 2.  The code below is around line 913 of genutils.py.  Do you know 
> which exceptions can this trigger under Windows, so we only trap those? 
> I don't like blanket except clauses (ipython has many, but I'm trying 
> to clean them up as much as possible).  I also added the inner 
> try/finally to ensure proper cleanup.

It turns out that there really weren't any exceptions possible there. 
That is fixed in the patch below as well.

> You can send me any new patches against current CVS.

$ diff genutils.py genutils.py.~1.7.~
912,922c912,925
<         if os.name == 'nt' and not pager_cmd.startswith('type'):
<             tmpname = tempfile.mktemp('.txt')
<             tmpfile = file(tmpname,'wt')
<             tmpfile.write(strng)
<             tmpfile.close()
<             cmd = pager_cmd + ' < ' + tmpname
<             if os.system(cmd):
<               retval = 1
<             else:
<               retval = None
<             os.remove(tmpname)
---
>         if os.name == 'nt':
>             try:
>                 try:
>                     tmpname = tempfile.mktemp('.txt')
>                     tmpfile = file(tmpname,'wt')
>                     tmpfile.write(strng)
>                     tmpfile.close()
>                     cmd = pager_cmd + ' < ' + tmpname
>                     os.system(cmd)
>                     retval = None
>                 finally:
>                     os.remove(tmpname)
>             except:  # FIXME: trap only the reasonable exceptions
>                 retval = 1

I have also uploaded changes to CVS for my readline library to make it 
work with 2.3. All the 2.3 stuff has been only very lightly tested 
because I don't run use it yet.

gb



More information about the IPython-dev mailing list