[ python-Bugs-1152762 ] curses.textpad raises error

SourceForge.net noreply at sourceforge.net
Thu Jun 2 02:12:23 CEST 2005


Bugs item #1152762, was opened at 2005-02-27 01:00
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1152762&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: John McPherson (jrm21)
>Assigned to: A.M. Kuchling (akuchling)
Summary: curses.textpad raises error

Initial Comment:
textpad seems to have a bug when you backspace from the
start of a line. By default, stripspaces is on, so it
tries to skip any spaces on the previous line. But if
there are no spaces, it raises a curses error and makes
the app quit.

Reproduce by:

$ python /usr/lib/python2.3/curses/textpad.py

type "1234567890" into the textpad

press backspace twice.

The problem is _end_of_line() function doing "last =
last + 1"

I think a better way would be to start at the end of
the line (last=self.maxx), and skip backwards while
"last" is a space:

        while last > 0 and ascii.ascii(self.win.inch(y,
last)) == ascii.SP:
            last -= 1

 

----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2005-06-01 20:12

Message:
Logged In: YES 
user_id=11375

Fix committed to 2-4-maint and HEAD.


----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2005-06-01 20:07

Message:
Logged In: YES 
user_id=11375

Thanks for reporting this problem!

Skipping backwards doesn't really solve the problem, because the function 
is supposed to return the index of the last space; even if you go 
backwards, you still need to increment 'last' by 1 to get the index of the 
space.  I think the fix is to do 'last = min(last+1, self.maxx)', and this is 
the fix I'll check in.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1152762&group_id=5470


More information about the Python-bugs-list mailing list