Title: test.test_curses.TestCurses.test_init_pair fails in s390x Fedora
Type: Stage: resolved
Components: Versions: Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-02-15 18:46 by pablogsal, last changed 2021-02-15 22:16 by pablogsal. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24539 merged pablogsal, 2021-02-15 19:51
PR 24541 merged pablogsal, 2021-02-15 21:53
Messages (7)
msg387042 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-15 18:46

ERROR: test_init_pair (test.test_curses.TestCurses)
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/", line 47, in wrapped
    test(self, *args, **kwargs)
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/", line 959, in test_init_pair
    curses.init_pair(maxpair, 0, 0)
ValueError: Color pair is greater than COLOR_PAIRS-1 (65535).
msg387043 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-15 18:52
This seems to happen only when running with -R
msg387048 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-15 19:27
The logic in _curses_init_pair_impl is quite odd. Seems that _CURSES_INIT_PAIR_FUNC succeeds the first run of (-R) even if pair_number >= COLOR_PAIRS but fails the second. Serhiy, do you know what's going on here?
msg387050 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-15 19:38
Hummmm, commenting out test_use_default_colors fixes the issue, so something is going on there
msg387051 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-15 19:45
From the curses docs:

       The init_pair routine changes the definition of a color-pair.  It
       takes three arguments: the number of the color-pair to be
       changed, the foreground color number, and the background color
       number.  For portable applications:

       •   The first argument must be a legal color pair value.  If
           default colors are used (see use_default_colors(3X)) the
           upper limit is adjusted to allow for extra pairs which use a
           default color in foreground and/or background.
msg387063 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-02-15 21:36
New changeset ab2d48163901c9635401db0f6d784c45482d17ec by Pablo Galindo in branch 'master':
bpo-43231: Fix test.test_curses.TestCurses.test_init_pair when running under -R (GH-24539)
msg387064 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-15 22:16
New changeset d0204963ec87beb9732e924e464b8a6a1ef4d341 by Pablo Galindo in branch 'master':
bpo-43231: Correctly calculate the curses color pair limit when checking for it (GH-24541)
Date User Action Args
2021-02-15 22:16:12pablogsalsetmessages: + msg387064
2021-02-15 22:16:05pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-02-15 21:53:02pablogsalsetpull_requests: + pull_request23327
2021-02-15 21:36:04lukasz.langasetmessages: + msg387063
2021-02-15 19:51:10pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23325
2021-02-15 19:45:15pablogsalsetmessages: + msg387051
2021-02-15 19:38:41pablogsalsetmessages: + msg387050
2021-02-15 19:27:53pablogsalsetmessages: + msg387048
2021-02-15 19:22:52pablogsalsetnosy: + lukasz.langa
2021-02-15 18:52:12pablogsalsetmessages: + msg387043
2021-02-15 18:46:09pablogsalsetversions: + Python 3.9, Python 3.10
2021-02-15 18:46:05pablogsalcreate