Thanks to visit codestin.com
Credit goes to github.com

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.16new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions