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

failure of test_colors_funcs in test_curses with ncurses 6.1 #80811

Closed
xdegaye mannequin opened this issue Apr 14, 2019 · 6 comments
Closed

failure of test_colors_funcs in test_curses with ncurses 6.1 #80811

xdegaye mannequin opened this issue Apr 14, 2019 · 6 comments
Labels
3.8 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@xdegaye
Copy link
Mannequin

xdegaye mannequin commented Apr 14, 2019

BPO 36630
Nosy @ned-deily, @xdegaye, @yan12125, @isidentical, @websurfer5
Superseder
  • bpo-36982: Add support for extended color functions in ncurses 6.1
  • Files
  • extended_pair_content.c: ncurses extended_pair_content() test program
  • 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 = None
    closed_at = <Date 2020-07-28.21:11:34.786>
    created_at = <Date 2019-04-14.19:32:58.045>
    labels = ['3.8', 'type-bug', 'tests']
    title = 'failure of test_colors_funcs in test_curses with ncurses 6.1'
    updated_at = <Date 2020-07-28.21:11:34.785>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2020-07-28.21:11:34.785>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-07-28.21:11:34.786>
    closer = 'ned.deily'
    components = ['Tests']
    creation = <Date 2019-04-14.19:32:58.045>
    creator = 'xdegaye'
    dependencies = []
    files = ['48338']
    hgrepos = []
    issue_num = 36630
    keywords = []
    message_count = 6.0
    messages = ['340228', '340253', '342885', '342956', '343342', '374529']
    nosy_count = 5.0
    nosy_names = ['ned.deily', 'xdegaye', 'yan12125', 'BTaskaya', 'Jeffrey.Kintscher']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '36982'
    type = 'behavior'
    url = 'https://bugs.python.org/issue36630'
    versions = ['Python 3.8']

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Apr 14, 2019

    ncurses version: 6.1
    TERM: screen-256color

    $  ./python -m test -u curses test_curses
    Run tests sequentially
    0:00:00 load avg: 0.55 [1/1] test_curses
    test test_curses failed -- Traceback (most recent call last):
      File "/path/to/Lib/test/test_curses.py", line 285, in test_colors_funcs
        curses.pair_content(curses.COLOR_PAIRS - 1)
    OverflowError: signed short integer is greater than maximum

    test_curses failed

    == Tests result: FAILURE ==

    Not sure if the following is relevant.

    In /usr/include/ncurses.h:

        NCURSES_WRAPPED_VAR(int, COLOR_PAIRS);
        ...
        #define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS())
        ...
        extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;

    ncurses 6.1 release notes [1] says:

    The TERMINAL structure in <term.h> is now opaque. Doing that allowed making the structure larger, to hold the extended numeric data.
    ...
    The new data in TERMINAL holds the same information as TERMTYPE, but with larger numbers (“int” versus “short”). It is named TERMTYPE2.
    

    [1] https://www.gnu.org/software/ncurses/

    @xdegaye xdegaye mannequin added 3.8 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Apr 14, 2019
    @yan12125
    Copy link
    Mannequin

    yan12125 mannequin commented Apr 15, 2019

    I asked on bug-ncurses mailing list and Thomas Dickey suggests "improving the python curses binding to handle the newer terminal descriptions". Looks like that requires non-trivial efforts. On the other hand, I've also found a workaround:

    $ TERM=xterm python -m test -u curses -v test_curses

    (or anything without -256color suffix for $TERM)

    How about setting TERM=xterm in tests and documenting that CPython does not support new terminal descriptions for now?

    [1] http://lists.gnu.org/archive/html/bug-ncurses/2019-04/msg00003.html

    @websurfer5
    Copy link
    Mannequin

    websurfer5 mannequin commented May 20, 2019

    The test fails because curses.pair_content(curses.COLOR_PAIRS-1) validates its parameter against the limits for signed short (max 32767) while curses.COLOR_PAIRS-1 has the value 65535.

    Unfortunately, re-plumbing curses.pair_content() to use signed integers instead of signed shorts and replacing the underlying ncurses API call from pair_content() to extended_pair_content() doesn't fix the problem because extended_pair_content() still fails when passed 65535. Tracing into the ncurses 6.1 source code, I found that start_color() clamps the maximum number of color pairs at SHRT_MAX (32767) regardless of the number of color pairs supported by the terminal.

    @websurfer5
    Copy link
    Mannequin

    websurfer5 mannequin commented May 20, 2019

    I posted a bug report to the bug-ncurses mailing list:

    https://lists.gnu.org/archive/html/bug-ncurses/2019-05/msg00022.html

    @websurfer5
    Copy link
    Mannequin

    websurfer5 mannequin commented May 24, 2019

    I created issue bpo-36982 to track the extended color changes since they broader than this issue.

    @ned-deily
    Copy link
    Member

    I believe this is now just a duplicate of bpo-36982. If there is anything not already covered there, let's discuss it there.

    @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.8 only security fixes 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