Index: Modules/readline.c =================================================================== --- Modules/readline.c (revision 78631) +++ Modules/readline.c (working copy) @@ -508,9 +508,6 @@ * code doesn't have to worry about the * difference. */ - HISTORY_STATE *hist_st; - hist_st = history_get_history_state(); - idx --; /* @@ -518,7 +515,7 @@ * the index is out of range, therefore * test for that and fail gracefully. */ - if (idx < 0 || idx >= hist_st->length) { + if (idx < 0 || idx >= history_length) { Py_RETURN_NONE; } } @@ -540,10 +537,7 @@ static PyObject * get_current_history_length(PyObject *self, PyObject *noarg) { - HISTORY_STATE *hist_st; - - hist_st = history_get_history_state(); - return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0); + return PyInt_FromLong(history_length); } PyDoc_STRVAR(doc_get_current_history_length, @@ -1024,29 +1018,21 @@ n = strlen(p); if (n > 0) { char *line; - HISTORY_STATE *state = history_get_history_state(); - if (state->length > 0) + if (history_length > 0) #ifdef __APPLE__ if (using_libedit_emulation) { /* * Libedit's emulation uses 0-based indexes, * the real readline uses 1-based indexes. */ - line = history_get(state->length - 1)->line; + line = history_get(history_length - 1)->line; } else #endif /* __APPLE__ */ - line = history_get(state->length)->line; + line = history_get(history_length)->line; else line = ""; if (strcmp(p, line)) add_history(p); - /* the history docs don't say so, but the address of state - changes each time history_get_history_state is called - which makes me think it's freshly malloc'd memory... - on the other hand, the address of the last line stays the - same as long as history isn't extended, so it appears to - be malloc'd but managed by the history package... */ - free(state); } /* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and release the original. */