forked from pool/python313
Add pass-test_write_read_limited_history.patch:
Fix readline history truncation when length is reduced The `readline.set_history_length()` function did not previously truncate the in-memory history when the new length was set to a value smaller than the current number of history items. This could lead to unexpected behavior where `get_history_length()` would still report the old length and writing the history to a file would write more entries than the new limit. This patch modifies `set_history_length()` to explicitly remove the oldest history entries using `remove_history()` when the length is decreased, ensuring the in-memory history is correctly truncated to the new limit. This brings the function's behavior in line with expectations and fixes failures in `test_write_read_limited_history`.
This commit is contained in:
45
pass-test_write_read_limited_history.patch
Normal file
45
pass-test_write_read_limited_history.patch
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
Modules/readline.c | 23 +++++++++++++++++++++++
|
||||||
|
1 file changed, 23 insertions(+)
|
||||||
|
|
||||||
|
Index: Python-3.13.9/Modules/readline.c
|
||||||
|
===================================================================
|
||||||
|
--- Python-3.13.9.orig/Modules/readline.c 2025-10-14 15:52:31.000000000 +0200
|
||||||
|
+++ Python-3.13.9/Modules/readline.c 2025-11-20 00:46:45.594286346 +0100
|
||||||
|
@@ -175,6 +175,8 @@
|
||||||
|
return PyUnicode_DecodeLocale(s, "surrogateescape");
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int _py_get_history_length(void);
|
||||||
|
+static void _py_free_history_entry(HIST_ENTRY *entry);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Explicitly disable bracketed paste in the interactive interpreter, even if it's
|
||||||
|
@@ -399,6 +401,27 @@
|
||||||
|
/*[clinic end generated code: output=e161a53e45987dc7 input=b8901bf16488b760]*/
|
||||||
|
{
|
||||||
|
_history_length = length;
|
||||||
|
+
|
||||||
|
+ if (length < 0) {
|
||||||
|
+ stifle_history(-1);
|
||||||
|
+ }
|
||||||
|
+ else {
|
||||||
|
+ int current_length = _py_get_history_length();
|
||||||
|
+ if (length < current_length) {
|
||||||
|
+#if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0500
|
||||||
|
+ HISTORY_STATE *state = history_get_history_state();
|
||||||
|
+ if (state) {
|
||||||
|
+ int i;
|
||||||
|
+ for (i = 0; i < current_length - length; i++) {
|
||||||
|
+ _py_free_history_entry(remove_history(0));
|
||||||
|
+ }
|
||||||
|
+ state->length = length;
|
||||||
|
+ free(state);
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+ }
|
||||||
|
+ stifle_history(length);
|
||||||
|
+ }
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,3 +1,24 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Nov 19 19:21:41 UTC 2025 - Matej Cepl <mcepl@suse.com>
|
||||||
|
|
||||||
|
- Add pass-test_write_read_limited_history.patch:
|
||||||
|
|
||||||
|
Fix readline history truncation when length is reduced
|
||||||
|
|
||||||
|
The `readline.set_history_length()` function did not previously
|
||||||
|
truncate the in-memory history when the new length was set to
|
||||||
|
a value smaller than the current number of history items. This
|
||||||
|
could lead to unexpected behavior where `get_history_length()`
|
||||||
|
would still report the old length and writing the history to a
|
||||||
|
file would write more entries than the new limit.
|
||||||
|
|
||||||
|
This patch modifies `set_history_length()` to explicitly
|
||||||
|
remove the oldest history entries using `remove_history()`
|
||||||
|
when the length is decreased, ensuring the in-memory history
|
||||||
|
is correctly truncated to the new limit. This brings the
|
||||||
|
function's behavior in line with expectations and fixes
|
||||||
|
failures in `test_write_read_limited_history`.
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Nov 13 17:13:03 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
Thu Nov 13 17:13:03 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,9 @@ Patch46: CVE-2025-8291-consistency-zip64.patch
|
|||||||
# PATCH-FIX-UPSTREAM CVE-2025-6075-expandvars-perf-degrad.patch bsc#1252974 mcepl@suse.com
|
# PATCH-FIX-UPSTREAM CVE-2025-6075-expandvars-perf-degrad.patch bsc#1252974 mcepl@suse.com
|
||||||
# Avoid potential quadratic complexity vulnerabilities in path modules
|
# Avoid potential quadratic complexity vulnerabilities in path modules
|
||||||
Patch47: CVE-2025-6075-expandvars-perf-degrad.patch
|
Patch47: CVE-2025-6075-expandvars-perf-degrad.patch
|
||||||
|
# PATCH-FIX-UPSTREAM pass-test_write_read_limited_history.patch bsc#[0-9]+ mcepl@suse.com
|
||||||
|
# Fix readline history truncation when length is reduced
|
||||||
|
Patch48: pass-test_write_read_limited_history.patch
|
||||||
BuildRequires: autoconf-archive
|
BuildRequires: autoconf-archive
|
||||||
BuildRequires: automake
|
BuildRequires: automake
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
|
|||||||
Reference in New Issue
Block a user