Skip to content

Commit b2faef2

Browse files
committed
gh-156347: Fix the documentation of curses window.encoding
The attribute is not used to encode str arguments on a build linked against a wide-character version of the curses library, which is the default: str is passed to curses as wide characters and the encoding of the current locale determines the bytes. It is used on a narrow build, where it also decodes results.
1 parent 8e3271d commit b2faef2

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Doc/howto/curses.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ the next subsection.
298298
The :meth:`~curses.window.addstr` method takes a Python string or
299299
bytestring as the value to be displayed. The contents of bytestrings
300300
are sent to the terminal as-is. Strings are encoded to bytes using
301-
the value of the window's :attr:`~window.encoding` attribute; this defaults to
302-
the default system encoding as returned by :func:`locale.getencoding`.
301+
the encoding of the current locale (see :func:`locale.getencoding`).
303302

304303
The :meth:`~curses.window.addch` methods take a character, which can be
305304
either a string of length 1, a bytestring of length 1, or an integer.

Doc/library/curses.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,11 @@ Other
20022002

20032003
.. attribute:: window.encoding
20042004

2005-
Encoding used to encode method arguments (Unicode strings and characters).
2005+
Encoding used to encode and decode method arguments and results
2006+
(Unicode strings and characters) on a narrow build. It is not used on a
2007+
build linked against a wide-character version of the underlying curses
2008+
library, where strings are passed to curses as wide characters and the
2009+
encoding of the current locale determines the bytes.
20062010
The encoding attribute is inherited from the parent window when a subwindow
20072011
is created, for example with :meth:`window.subwin`.
20082012
By default, current locale encoding is used (see :func:`locale.getencoding`).

0 commit comments

Comments
 (0)