Skip to content

curses: error when adding a symbol to the bottom right corner of the window #131908

@pikhovkin

Description

@pikhovkin

Bug report

Bug description:

import curses

def main(stdscr):
    stdscr.clear()
    # height, width = stdscr.getmaxyx()
    height, width = curses.LINES, curses.COLS
    win = curses.newwin(height, width, 0, 0)
    win.addstr(0, 0, '+')
    win.addstr(0, width - 1, '+')  # width - 1: no error
    # win.addstr(height - 1, width - 2, '+')  # width - 2: no error
    win.addstr(height - 1, width - 1, '+')  # width - 1: error
    # win.addch(height - 1, width - 1, '+')  # width - 1: error
    win.addstr(height - 1, 0, '+')
    win.touchwin()
    win.refresh()
    win.getch()

if __name__ == '__main__':
    curses.update_lines_cols()
    curses.wrapper(main)
Traceback (most recent call last):
  File "/.../demo.py", line 20, in <module>
    curses.wrapper(main)
    ~~~~~~~~~~~~~~^^^^^^
  File "/.../3.13.2/lib/python3.13/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/.../demo.py", line 11, in main
    win.addstr(height - 1, width - 1, '+')  # width - 1: error
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_curses.error: addwstr() returned ERR

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions