Skip to content

Accept curses.complexchar in curses.ascii predicates and conversions #153395

Description

@serhiy-storchaka

This is a follow-up of gh-151757, which added wide-character support and the curses.complexchar character-cell type.

That type cannot currently be passed to the curses.ascii functions, so code that reads a cell -- for example via curses.window.in_wch() -- and wants to classify it with curses.ascii has to unwrap it by hand first.

The membership predicates (isalpha(), isdigit(), isprint(), iscntrl(), ...) and the ctrl() and unctrl() conversions should also accept a complexchar, classifying it by its single character. A cell that holds combining characters is not a single character, so the predicates return false for it.

While there, ctrl() should be a no-op for a non-ASCII argument. There is no control character outside ASCII, and masking the code to 0x1f (as it does now) just yields an unrelated control byte.

ascii(), alt() and ismeta() remain meaningless for non-8-bit codes, a complexchar included.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions