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: Prevent duplicates in readline history
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: skip.montanaro Nosy List: gvanrossum, skip.montanaro
Priority: normal Keywords: patch

Created on 2002-05-30 17:47 by skip.montanaro, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
readline.diff skip.montanaro, 2002-05-30 17:47
Messages (5)
msg40187 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-05-30 17:47
Someone complained awhile back on c.l.py that Python's readline 
history gets duplicates when you ^P to reexecute the previous 
command.  I believe the attached patch fixes that.  As far as I could 
tell, the memory returned by history_get_history_state() is malloc'd, 
though that's not documented in the version of the history docs I 
have and I didn't have the source handy to check.  Someone needs 
to verify that before any such change is incorporated into the code 
base.  (I will download the readline/history source and check if 
nobody else can confirm easily.)

Note that I also added a call to using_history() in setup_readline().  I 
believe that's what the history docs indicate you should do, though it 
doesn't seem to be strictly necessary.

Skip
msg40188 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-05 21:59
Logged In: YES 
user_id=6380

I like this idea, but I suggest that you check the readline 
source to confirm your hypothesis about the need to free
(state). You might want to check different versions of readline 
too -- we're trying to be compatible with readline 2.2 through 
4.x.
msg40189 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-06-07 20:15
Logged In: YES 
user_id=44345

I checked the readline 2.0 and 4.2a sources (the oldest and newest tarballs 
available from ftp.gnu.org).  The history_get_history_state function in both 
versions malloc's the state.

Skip
msg40190 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-10 21:11
Logged In: YES 
user_id=6380

OK, then go for it.
msg40191 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-06-11 14:33
Logged In: YES 
user_id=44345

incorporated as Modules/readline.c 2.50
History
Date User Action Args
2022-04-10 16:05:22adminsetgithub: 36669
2002-05-30 17:47:33skip.montanarocreate