gh-122431: Disallow negative values in readline.append_history_file (#122469)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Peter Bierma 2024-12-05 11:07:38 -05:00 committed by GitHub
parent 67b9a5331a
commit 208b0fb645
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -114,6 +114,14 @@ class TestHistoryManipulation (unittest.TestCase):
# write_history_file can create the target
readline.write_history_file(hfilename)
# Negative values should be disallowed
with self.assertRaises(ValueError):
readline.append_history_file(-42, hfilename)
# See gh-122431, using the minimum signed integer value caused a segfault
with self.assertRaises(ValueError):
readline.append_history_file(-2147483648, hfilename)
def test_nonascii_history(self):
readline.clear_history()
try: