Modules/readline.c contains a workaround for a bug in the readline emulation of libedit: that emulation uses a different starting offset for the history than the real readline.
In more recent versions of libedit (such as the one you can now download from <http://www.thrysoee.dk/editline/>) the bug has been fixed and the workaround causes problems.
The attached patch dynamicly detects if the workaround is necessary.
NOTE: Actually using the trysoee.dk libedit requires a patch to setup.py, that version of libedit does not install libreadline.dylib, only libedit.dylib.