Skip to content

Conversation

PrinceNaroliya
Copy link
Contributor

@PrinceNaroliya PrinceNaroliya commented Aug 23, 2025

Documentation fix

This PR clarifies the wording in the curses.color_pair documentation.

Previously it said:

This attribute value can be combined with A_STANDOUT, A_REVERSE, and the other A_* attributes.

This was ambiguous because constants like A_COLOR, A_ATTRIBUTES, and A_CHARTEXT also follow the A_* pattern, but those are extraction masks and cannot be combined with curses.color_pair().

Changes made

  • Updated Doc/library/curses.rst:
    • Explicitly clarified that the value returned by curses.color_pair(n) is an attribute mask that can be combined (using |) with style attributes like A_BOLD, A_REVERSE, A_UNDERLINE.
    • Added a note that A_COLOR, A_ATTRIBUTES, and A_CHARTEXT are extraction masks used with & on values returned from window.inch(), and must not be combined with color_pair().

Why this is needed

  • Avoids confusion for new users who may assume all A_* constants can be OR'ed with curses.color_pair.
  • Matches the behavior of curses in practice.

Example

# Valid
attr = curses.color_pair(3) | curses.A_BOLD | curses.A_REVERSE
win.addstr("Hello", attr)

# Invalid (no effect, misleading)
attr = curses.color_pair(3) | curses.A_COLOR


<!-- gh-issue-number: gh-138071 -->
* Issue: gh-138071
<!-- /gh-issue-number -->


<!-- readthedocs-preview cpython-previews start -->
----
📚 Documentation preview 📚: https://cpython-previews--138079.org.readthedocs.build/

<!-- readthedocs-preview cpython-previews end -->

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too verbose. I don't think we need to change this. A_* attributes are well-defined. A_COLOR is not categorized as an attribute in the corresponding table. Sorry, but I'm going to close this one.

@picnixz picnixz closed this Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants