https://github.com/python/cpython/commit/d831a690766e92b3be5e40134f64407bd041bcbf
commit: d831a690766e92b3be5e40134f64407bd041bcbf
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-06-28T17:03:22+03:00
summary:

gh-87881: Document the result of curses inch() and getbkgd() (GH-152488)

Explain the character/attribute bit layout and how to extract the parts
(A_CHARTEXT and A_ATTRIBUTES bit-masks, pair_number() for the color pair),
or use in_wch() to get a complexchar.

Co-authored-by: Claude Opus 4.8 <[email protected]>

files:
M Doc/library/curses.rst

diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst
index 8d069ed8b7d1c4..f87ab7a8ee063d 100644
--- a/Doc/library/curses.rst
+++ b/Doc/library/curses.rst
@@ -1332,6 +1332,7 @@ Window objects
 .. method:: window.getbkgd()
 
    Return the given window's current background character/attribute pair.
+   Its components can be extracted like those of :meth:`inch`.
    It cannot represent a background set with a wide character or with a color
    pair outside the :func:`color_pair` range; use :meth:`getbkgrnd` for those.
 
@@ -1486,11 +1487,13 @@ Window objects
 
 .. method:: window.inch([y, x])
 
-   Return the character at the given position in the window. The bottom 8 bits 
are
-   the character proper, and upper bits are the attributes.
+   Return the character at the given position in the window.
+   The bottom 8 bits are the character proper and the upper bits are the 
attributes;
+   extract them with the :data:`A_CHARTEXT` and :data:`A_ATTRIBUTES` bit-masks,
+   and the color pair with :func:`pair_number`.
    It cannot represent a cell holding combining characters, a character that 
does
    not fit in a single byte, or a color pair outside the :func:`color_pair`
-   range; use :meth:`in_wch` for those.
+   range; use :meth:`in_wch` for those, which returns it as a 
:class:`complexchar`.
 
 
 .. method:: window.in_wch([y, x])

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to