Skip to content

curses border() and box() no longer accept 0 with a str #155499

Description

@fedonman

Bug description:

curses.window.border() and curses.window.box() raise TypeError on a build with ncursesw when one argument is a one-character str and another is 0, which both border.__doc__ and Doc/library/curses.rst document as the request for that parameter's default character:

import curses

def main(stdscr):
    win = curses.newwin(5, 10, 0, 0)
    win.border('|', '|', '-', '-')             # default corners: works
    win.border('|', '|', '-', '-', 0, 0, 0, 0) # documented as the same thing

curses.wrapper(main)
    win.border('|', '|', '-', '-', 0, 0, 0, 0) # documented as the same thing
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: border() cannot mix integer or bytes characters with wide string characters

On 3.14.4 the same script exits 0. win.box('|', 0) and win.box(0, '-') fail the same way.

The restriction on mixing characters is intended (gh-151757), but the documented 0 sentinel now counts as an integer character.

Expected: 0 keeps meaning "use the default" on this path, or Doc/library/curses.rst records that 0 cannot appear in a call that also passes a str.

Introduced by GH-151758.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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