This catches errors in readline_no_record which occur with pyreadline <1.7.
To discuss: at present, if there are errors, we don't reset readline history. This saves us a relatively expensive operation, but it means that if you do, e.g. %debug in this situtation, the extra commands you enter are kept in readline history. It's easy to change that to always reset readline history, if we prefer.
Catch errors in querying readline which occur with pyreadline.
Thanks, Fernando. Jörgen says that it works on his system with this change - shall I go ahead and merge?