Skip to content

curses.window.addstr() and friends lose an extended color pair #156138

Description

@serhiy-storchaka

Bug report

window.addstr(str, attr) restores the window rendition after the write with wattrset(), whose chtype cannot hold a color pair above 255, so a window using an extended pair loses it.

import curses

def check(stdscr):
    curses.start_color()
    curses.init_pair(300, curses.COLOR_RED, curses.COLOR_BLACK)
    win = curses.newwin(2, 10, 0, 0)
    win.color_set(300)
    win.addstr(0, 0, 'x', curses.A_BOLD)
    return win.attr_get()

print(curses.wrapper(check))     # (0, 0), want (0, 300)

addnstr(), insstr() and insnstr() do the same. wattr_get() and wattr_set() keep the pair.

Extended pairs became settable on a window in 3.16 (gh-152219), so this affects the main branch only.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions