From b2226509f048934611a835a3157fac59bc86c7f7 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Tue, 24 Jun 2008 19:16:29 +0100 Subject: [PATCH] Now 2.4-compatible. As far as I know this should run fine on 2.4 without any problems. Thanks a bunch to Seamus for making me have to write ugly code to make bpython compatible with his computer from the 1800s. --- CHANGELOG | 9 +++++++++ bpython.py | 14 +++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a525f2e..2c44cfd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,12 @@ +v0.6.0 +====== +No noticeable changes except that bpython should now work with +Python 2.4. Personally I think it's silly to make a development +tool work with an out of date version of Python but some people +seem to disagree. The only real downside is that I had to do a +horrible version of all() using reduce(), otherwise there's no +real differences in the code. + v0.5.3 ====== Now you can configure a ~/.bpythonrc file (or pass a rc file at the diff --git a/bpython.py b/bpython.py index b5d9859..3aea7f9 100644 --- a/bpython.py +++ b/bpython.py @@ -409,7 +409,10 @@ class Repl( object ): y, x = self.scr.getyx() h, w = self.scr.getmaxyx() down = (y < h / 2) - max_h = h - y if down else y+1 + if down: + max_h = h - y + else: + max_h = y+1 max_w = int(w * 0.6) self.list_win.erase() @@ -1060,7 +1063,9 @@ class Repl( object ): sl = sorted( l, key=str.__len__ ) for i, c in enumerate( l[-1] ): - if not all( k.startswith( l[-1][:i] ) for k in sl ): + if not reduce( lambda x, y: (x and y) or False, + ( k.startswith( l[-1][:i] ) for k in sl ), + True ): break return l[-1][:i-1] @@ -1434,6 +1439,9 @@ def loadrc(): if hasattr( OPTS, k ): setattr( OPTS, k, v ) + if not "pyparsing" in sys.modules: + OPTS.arg_spec = False + stdscr = None def main( scr ): @@ -1478,7 +1486,7 @@ try: o = curses.wrapper( main ) except: tb = traceback.format_exc() -finally: # I don't know why this is necessary; without it the wrapper doesn't always +# I don't know why this is necessary; without it the wrapper doesn't always # do its job. if stdscr is not None: stdscr.keypad(0)