windows-curses icon indicating copy to clipboard operation
windows-curses copied to clipboard

color_content() fails above color 15 and pair_number() result needs shifting to use

Open pjfarleyiii opened this issue 4 years ago • 0 comments

I have found two issues with the current release of windows-curses:

  1. The color_content() function fails for any color number above 15, while in an *ix ncurses environment it returns values (although they are not correct values in my testing so far).
  2. The pair_number() function on Windows only returns a value that must be shifted right by 16 bits before it can be used as the argument to the pair_content() function. In an *ix ncurses environment the shift is not required.

For issue 2, if the shift is not done then the program crashes with these error messages at the call to pair_content().

Traceback (most recent call last): File "C:\test\wincurses-issues.py", line 60, in curses.wrapper(main) File "C:\Python38\lib\curses_init_.py", line 105, in wrapper return func(stdscr, *args, **kwds) File "C:\test\wincurses-issues.py", line 49, in main fg, bg = curses.pair_content (pair) OverflowError: signed short integer is greater than maximum

Code to show the two problems is attached as a *.txt file. Rename to *.py to run the example. Comment out the test for windows and the pair shift to observe the crash.

Environments tested: Win 10-64 Python 3.8.9 (tags/v3.8.9:a743f81, Apr 6 2021, 14:02:34) [MSC v.1928 64 bit (AMD64)] windows-curses 2.2.0

Ubuntu 20.04 (Win 10 / WSL2) libncurses6/focal,now 6.2-0ubuntu2 amd64

Peter

wincurses-issues.txt

pjfarleyiii avatar Apr 11 '21 06:04 pjfarleyiii