Skip to content

curses.tparm() crashes for capabilities that take string parameters #161571

Done

Description

@serhiy-storchaka

Bug description:

curses.tparm() passes all its parameters as integers. But ncurses treats some parameters as char *, for the few capabilities that take strings: pfkey, pfloc, pfx, pln, pfxl, and the extended Cs and Ms of xterm. So passing an integer there crashes:

import curses
curses.setupterm('xterm-256color')
curses.tparm(curses.tigetstr('Ms'), 1)    # Segmentation fault

The same happens with curses.tigetstr('Cs'). There is also no way to pass a string, so these capabilities cannot be used from Python at all.

ncurses takes as strings the parameters for which %s or %l directly follows %pN, but only in the format strings of the capabilities above of the current terminal. For other format strings with such parameters it returns NULL, so a plain b'%p1%s' does not crash: tparm() raises curses.error.

NetBSD curses takes such parameters as strings in any format string, not only in those capabilities, so with it even curses.tparm(b'x%p1%sy', 1) crashes.

Linked PRs

Activity

  1. added
    extension-modules
    type-crash
    3.14
    3.15
    3.16
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 24, 2026
  3. added 2 commits that reference this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.143.153.16extension-modulestopic-cursestype-crash

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions