[IPython-dev] Prefilter Cleanup

Dan Milstein danmil at comcast.net
Fri Mar 16 11:54:06 EDT 2007


Okay, so I've finished up my private-copy rewrite of the prefiltering  
code.  It turned out to be a decent-sized refactoring, so holding off  
on merging it until after 0.7.4 probably makes sense.

In fact, if things still seem on track for that release, I'll hold  
off on posting patches until then, because I want to make sure that  
everything still works (I made a separate prefilter module and moved  
a bunch of iplib stuff into there).

That said, a few teasers:

  - Here's how the main block of prefilter code now looks:

     for check in [ checkEscChars,
                    checkEmacs,
                    checkMultiLineShell,
                    checkPythonChars,
                    checkAutomagic,
                    checkAlias,
                    checkAutocall,
                    ]:
         handler = check(line_info, ip)
         if handler:
             return handler(line_info)

     return ip.handle_normal(line_info)


Each check sees if the line matches a pattern, and if it does,  
returns a handler to transform the line.  So the sequence of possible  
handlers is totally explicit, and all the hairy sharing of partially  
parsed lines is gone.


  - Cleaned up a few subtle edge cases

Various things I asked about in previous emails now work in non- 
surprising ways.  And some other, very subtle things, having to do  
with order of namespace shadowing, attribute lookups and the like,  
also now work in non-surprising ways.


  - More tests

I added tests to check that the handlers were doing their jobs right,  
and various other tests as I ran into subtle issues.  Decently  
thorough set, and more can be added.


-Dan



More information about the IPython-dev mailing list