Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_readline when compiled using --with-readline=edit #87338

Closed
gpshead opened this issue Feb 9, 2021 · 5 comments
Closed

Fix test_readline when compiled using --with-readline=edit #87338

gpshead opened this issue Feb 9, 2021 · 5 comments
Assignees
Labels
3.10 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@gpshead
Copy link
Member

gpshead commented Feb 9, 2021

BPO 43172
Nosy @gpshead
PRs
  • bpo-43172: readline now passes its tests when built against libedit #24499
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gpshead'
    closed_at = <Date 2021-02-12.20:05:25.734>
    created_at = <Date 2021-02-09.01:40:34.034>
    labels = ['tests', 'type-bug', 'library', '3.10']
    title = 'Fix test_readline when compiled using --with-readline=edit'
    updated_at = <Date 2021-02-12.20:05:25.733>
    user = 'https://github.com/gpshead'

    bugs.python.org fields:

    activity = <Date 2021-02-12.20:05:25.733>
    actor = 'gregory.p.smith'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2021-02-12.20:05:25.734>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2021-02-09.01:40:34.034>
    creator = 'gregory.p.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43172
    keywords = ['patch']
    message_count = 5.0
    messages = ['386681', '386682', '386685', '386687', '386876']
    nosy_count = 1.0
    nosy_names = ['gregory.p.smith']
    pr_nums = ['24499']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43172'
    versions = ['Python 3.10']

    @gpshead
    Copy link
    Member Author

    gpshead commented Feb 9, 2021

    https://bugs.python.org/issue13501 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/test_readline.py", 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/test_readline.py", 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/test_readline.py", 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/test_readline.py", 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?

    @gpshead gpshead added the 3.10 only security fixes label Feb 9, 2021
    @gpshead gpshead self-assigned this Feb 9, 2021
    @gpshead gpshead added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error 3.10 only security fixes labels Feb 9, 2021
    @gpshead gpshead self-assigned this Feb 9, 2021
    @gpshead gpshead added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Feb 9, 2021
    @gpshead
    Copy link
    Member Author

    gpshead commented Feb 9, 2021

    Motivation: I want to add --with-readline=edit to the configure flags of one of my buildbot configs via an edit to https://github.com/python/buildmaster-config/tree/master/master/custom

    @gpshead
    Copy link
    Member Author

    gpshead commented Feb 9, 2021

    python/buildmaster-config#229 tracks my buildbot config update

    @gpshead
    Copy link
    Member Author

    gpshead commented Feb 9, 2021

    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).

    @gpshead
    Copy link
    Member Author

    gpshead commented Feb 12, 2021

    New changeset fd053fd by Gregory P. Smith in branch 'master':
    bpo-43172: readline now passes its tests when built against libedit (GH-24499)
    fd053fd

    @gpshead gpshead closed this as completed Feb 12, 2021
    @gpshead gpshead closed this as completed Feb 12, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant