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.

Title: Fix test_readline when compiled using --with-readline=edit
Type: behavior Stage: commit review
Components: Library (Lib), Tests Versions: Python 3.10
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: gregory.p.smith
Priority: normal Keywords: patch

Created on 2021-02-09 01:40 by gregory.p.smith, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24499 merged gregory.p.smith, 2021-02-10 06:17
Messages (5)
msg386681 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-02-09 01:40 added configure --with-readline=edit support so that the readline module can build and link against libedit on any platform instead of only using libreadline.

Building Python that way on Debian Linux and running test_readline results in a variety of test failure for me:

== CPython 3.10.0a5+ (heads/master-dirty:e1f7769513, Feb 9 2021, 01:20:59) [GCC 10.2.1 20210110]
== cwd: /home/gps/oss/cpython/b/build/test_python_1681021æ
== CPU count: 16
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 0.47 Run tests sequentially
0:00:00 load avg: 0.47 [1/1] test_readline
readline version: 0x402
readline runtime version: 0x402
readline library version: 'EditLine wrapper'
use libedit emulation? True
testHistoryUpdates (test.test_readline.TestHistoryManipulation) ... ERROR
test_nonascii_history (test.test_readline.TestHistoryManipulation) ... FAIL
test_write_read_append (test.test_readline.TestHistoryManipulation) ... FAIL
test_auto_history_disabled (test.test_readline.TestReadline) ... ok
test_auto_history_enabled (test.test_readline.TestReadline) ... ok
test_history_size (test.test_readline.TestReadline) ... skipped 'this readline version does not support history-size'
test_init (test.test_readline.TestReadline) ... ok
test_nonascii (test.test_readline.TestReadline) ... FAIL

ERROR: testHistoryUpdates (test.test_readline.TestHistoryManipulation)
Traceback (most recent call last):
  File "/home/gps/oss/cpython/gpshead/Lib/test/", line 59, in testHistoryUpdates
    readline.replace_history_item(0, "replaced line")
ValueError: No history item at position 0

FAIL: test_nonascii_history (test.test_readline.TestHistoryManipulation)
Traceback (most recent call last):
  File "/home/gps/oss/cpython/gpshead/Lib/test/", line 127, in test_nonascii_history
    self.assertEqual(readline.get_history_item(1), "entrée 1")
AssertionError: 'entrée 22' != 'entrée 1'
- entrée 22
?        ^^
+ entrée 1
?        ^

FAIL: test_write_read_append (test.test_readline.TestHistoryManipulation)
Traceback (most recent call last):
  File "/home/gps/oss/cpython/gpshead/Lib/test/", line 98, in test_write_read_append
    self.assertEqual(readline.get_current_history_length(), 3)
AssertionError: 4 != 3

FAIL: test_nonascii (test.test_readline.TestReadline)
Traceback (most recent call last):
  File "/home/gps/oss/cpython/gpshead/Lib/test/", line 231, in test_nonascii
    self.assertIn(b"indexes 11 13\r\n", output)
AssertionError: b'indexes 11 13\r\n' not found in bytearray(b"^A^B^B^B^B^B^B^B\t\tx\t\r\n[\xc3\xafnserted]|t\xc3\xab[after]\x08\x08\x08\x08\x08\x08\x08text \'t\\xeb\'\r\nline \'[\\xefnserted]|t\\xeb[after]\'\r\nindexes 10 12\r\n\x07\r\x1b[14Gtext \'t\\xeb\'\r\nline \'[\\xefnserted]|t\\xeb[after]\'\r\nindexes 10 12\r\n\r\nt\xc3\xabnt t\xc3\xabxt\r\n\r\x1b[K[\xc3\xafnserted]|t\xc3\xab[after]\x1b[14G\r\x1b[14G\x1b[1@x[\x08\x07\r\x1b[15G\x1b[1@t[\x08\r\nresult \'[\\xefnserted]|t\\xebxt[after]\'\r\nhistory \'[\\xefnserted]|t\\xebxt[after]\'\r\n")


Ran 8 tests in 0.123s

FAILED (failures=3, errors=1, skipped=1)

I suspect these are just behavior differences in the library and some tests need to be skipped or test alternate behavior in this situation?
msg386682 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-02-09 01:41
Motivation: I want to add --with-readline=edit to the configure flags of one of my buildbot configs via an edit to
msg386685 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-02-09 01:46 tracks my buildbot config update
msg386687 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-02-09 02:39
examining the behaviors being tested, it seems there are differences in 0 and 1 based indexing behaviors between libreadline and libedit.

libedit frankly seems more consistent.  but the Python readline module docs document the 0 and 1 based quirks as part of the module API.  We may need to adjust for these based on direct libedit use vs libreadline within the module code.

it appears code doing such adjustments already exists on macOS (i haven't yet looked in the module code or if Darwin as a platform does it in their readline shim around libedit).
msg386876 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-02-12 20:04
New changeset fd053fdd39fbdf114b4218ea4309666bafa95788 by Gregory P. Smith in branch 'master':
bpo-43172: readline now passes its tests when built against libedit (GH-24499)
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87338
2021-02-12 20:05:25gregory.p.smithsetstatus: open -> closed
resolution: fixed
stage: patch review -> commit review
2021-02-12 20:04:59gregory.p.smithsetmessages: + msg386876
2021-02-10 06:17:51gregory.p.smithsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request23288
2021-02-09 02:39:22gregory.p.smithsetmessages: + msg386687
2021-02-09 01:46:45gregory.p.smithsetmessages: + msg386685
2021-02-09 01:41:36gregory.p.smithsetmessages: + msg386682
2021-02-09 01:40:34gregory.p.smithcreate