[issue16293] curses.ungetch raises OverflowError when given -1

Julian Berman report at bugs.python.org
Sun Oct 21 15:53:03 CEST 2012


Julian Berman added the comment:

Hi, sorry for being terse :).

After checking a bit, man 3 getch says that it returns ERR (-1) in non-blocking mode if no input is available. I think you're right though -- calling ungetch without checking for the error value seems like it should be a bug in the application, and looking at some examples that seems to be correct.

The reason this came up though is because the changes to range checking broke bpython, which does something like the code I pasted in the first post. The reason it appears to have worked before is because later on getkey is called, and getkey checks if it got ERR and converts that to an exception, which was being caught and silenced. Now though, the code will fail at the call to ungetch.

So, I guess, besides the change in behavior, which I guess is less bug prone before so it's probably desirable, OverflowError sounds scary. Perhaps ungetch should check for -1 and raise a curses.error instead?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16293>
_______________________________________


More information about the Python-bugs-list mailing list