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.

classification
Title: curses.pair_number() function incorrect value under Windows
Type: Stage: resolved
Components: Extension Modules Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: pjfarleyiii, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-04-03 19:34 by pjfarleyiii, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
curses-color-1.py pjfarleyiii, 2021-04-03 19:34 curses progrm demonstrating issue
Messages (3)
msg390137 - (view) Author: Peter J. Farley III (pjfarleyiii) Date: 2021-04-03 19:34
curses.pair_number() result under Windows (console or Terminal window) value must be shifted by 16 bits to be valid to use as input to the curses.pair_content() function.

If the pair number result is not shifted, the call to curses.pair_content() fails with an overflow error:

Traceback (most recent call last):
  File "C:\Users\MyUser\test\curses-color.py", line 126, in <module>
    curses.wrapper(main)
  File "C:\Python38\lib\curses\__init__.py", line 105, in wrapper
    return func(stdscr, *args, **kwds)
  File "C:\Users\MyUser\test\curses-color.py", line 72, in main
    fg, bg = curses.pair_content (pair)
OverflowError: signed short integer is greater than maximum

The attached curses program demonstrates the correct functioning using the pair value shift under Windows.  Comment out the "if" and shift lines to reproduce the overflow error.

Environment information:

Windows 10 (latest updates)
Windows cmd.exe window or Windows Terminal Version: 1.6.10571.0
Python 3.8.7
windows-curses 2.2.0

Also tested in:

Ubuntu 20.04 (WSL2)
ncurses6/focal,now 6.2-0ubuntu2 amd64
msg390447 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-04-07 16:57
The curses module is not supported on Windows. windows-curses is a third-party library. Use the corresponding bug tracker to report an issue with windows-curses.
msg390696 - (view) Author: Peter J. Farley III (pjfarleyiii) Date: 2021-04-10 06:15
Thank you for responding.  I will pursue the issue with the windows-curses
and/or PDCurses team.

Peter

On Wed, Apr 7, 2021 at 12:57 PM Serhiy Storchaka <report@bugs.python.org>
wrote:

>
> Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:
>
> The curses module is not supported on Windows. windows-curses is a
> third-party library. Use the corresponding bug tracker to report an issue
> with windows-curses.
>
> ----------
>
>
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87882
2021-04-10 06:15:01pjfarleyiiisetmessages: + msg390696
2021-04-07 16:57:11serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg390447

resolution: third party
stage: resolved
2021-04-03 19:34:11pjfarleyiiicreate