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.

Author tycho
Recipients tycho
Date 2011-09-28.00:47:08
SpamBayes Score 5.8828498e-12
Marked as misclassified No
Message-id <1317170831.29.0.145546521568.issue13051@psf.upfronthosting.co.za>
In-reply-to
Content
The attached patch fixes two bugs which manifest as infinite recursion in _insert_printable_char() of Textbox. First, the previous implementation of _insert_printable_char() used recursion to move characters when inserting a character. Thus, any Textpad which had an area greater than the interpreter's maximum recursion limit would crash. A minimal test case is the following:

#!/usr/bin/python
import curses
from curses.textpad import Textbox

def main(stdscr):
    box = Textbox(stdscr, insert_mode=True)
    box.stripspaces = True
    while 1:
        cmd = box.edit()
        if cmd == 'q':
            break

curses.wrapper(main)

Run that script in a terminal with area (i.e. $LINES * $COLUMNS) > 1000 (the default max recursion limit), press any key and be greeted by a stack trace. The patch changes the implementation of _insert_printable_char() to be iterative, thus avoiding the infinite recursion.

Second, when the underlying curses window was resized to be smaller than it was when the Textpad was created, pressing any key would result in infinite recursion (or with the new method, an infinite loop). The patch also changes Textpad so that instead of keeping the underlying window's size as instance attributes of this Textpad, Textpad asks the underlying window its size every time Textpad needs to know, allowing the underlying window to be resized at will.

I've verified this bug is in 2.7.1 and 3.2. Let me know if you need anything else.
History
Date User Action Args
2011-09-28 00:47:11tychosetrecipients: + tycho
2011-09-28 00:47:11tychosetmessageid: <1317170831.29.0.145546521568.issue13051@psf.upfronthosting.co.za>
2011-09-28 00:47:10tycholinkissue13051 messages
2011-09-28 00:47:09tychocreate