This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: curses.textpad raises error
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, jrm21
Priority: normal Keywords:

Created on 2005-02-27 06:00 by jrm21, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg24378 - (view) Author: John McPherson (jrm21) Date: 2005-02-27 06:00
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

 
msg24379 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-06-02 00:07
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.
msg24380 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-06-02 00:12
Logged In: YES 
user_id=11375

Fix committed to 2-4-maint and HEAD.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41626
2005-02-27 06:00:48jrm21create