GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — curses `window.encoding` does not encode `str` arguments on a wide build · Issue #156347 · python/cpython

curses window.encoding does not encode str arguments on a wide build #156347

New issue
Copy link
New issue
Copy link
Closed
Closed
curses window.encoding does not encode str arguments on a wide build#156347
Copy link
Assignees
serhiy-storchaka
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-curses

Description

@fedonman
fedonman
opened on Aug 25, 2026
Issue body actions

Documentation

The curses HOWTO says that strings passed to window.addstr() are "encoded to bytes using the value of the window's encoding attribute", and the window.encoding entry in the library reference describes it as the "Encoding used to encode method arguments (Unicode strings and characters)". On a build linked against a wide-character version of the curses library, which is what CPython configures by default, neither is true: PyCurses_ConvertToString in Modules/_cursesmodule.c converts str with PyUnicode_AsWideCharString and never reads win->encoding, so the bytes that reach the terminal come from the current locale instead.

import curses, os, pty, sys
_, slave = pty.openpty()
os.dup2(slave, 0); os.dup2(slave, 1)
win = curses.initscr()
win.encoding = 'latin-1'
win.addstr(0, 0, 'caf\xe9')
got = win.instr(0, 0, 6)
curses.endwin()
print('stored:', got, '  latin-1 would be:', 'caf\xe9'.encode('latin-1'), file=sys.stderr)
stored: b'caf\xc3\xa9 '   latin-1 would be: b'caf\xe9'

Expected: b'caf\xe9', the bytes latin-1 produces, if window.encoding were used to encode the argument.

The attribute is used on a narrow build, where it also decodes results, so the correction has to name the build rather than call the attribute unused.

Linked PRs

  • gh-156347: Fix the documentation of curses window.encoding #156352
  • gh-156347: Fix wrong statements in the curses documentation #156354
  • [3.15] gh-156347: Fix wrong statements in the curses documentation (GH-156354) #156872
  • [3.14] gh-156347: Fix wrong statements in the curses documentation (GH-156354) #156873
  • [3.13] gh-156347: Fix wrong statements in the curses documentation (GH-156354) #156874

Activity

  1. serhiy-storchaka
    self-assigned this
    on Aug 25, 2026
  2. serhiy-storchaka
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    topic-curses
    on Aug 25, 2026
  3. github-project-automation
    added this to docs issueson Aug 25, 2026
  4. github-project-automation
    moved this to Todo in docs issueson Aug 25, 2026
  5. serhiy-storchaka
    added this to Curses issueson Aug 25, 2026
  6. serhiy-storchaka commented on Aug 25, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Aug 25, 2026
    Member
    More actions

    There are many other wrong statements in the curses HOWTO. #156354 fixes them and slightly modernizes the documentation.

  7. fedonman commented on Aug 25, 2026

    @fedonman
    fedonman
    on Aug 25, 2026
    ContributorAuthor
    More actions

    @serhiy-storchaka I had already opened #156352 Should I close it?

  8. serhiy-storchaka commented on Aug 27, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Aug 27, 2026
    Member
    More actions

    Yes, I think it is superseded by #156354.

  9. serhiy-storchaka
    added 3 commits that reference this issue on Sep 3, 2026

    gh-156347: Fix wrong statements in the curses documentation (GH-156354)

    161054c

    [3.14] gh-156347: Fix wrong statements in the curses documentation (G…

    a3084ff

    [3.13] gh-156347: Fix wrong statements in the curses documentation (G…

    6ad0c73
  10. serhiy-storchaka
    closed this as completedon Sep 3, 2026
  11. github-project-automation
    moved this to Done in Curses issueson Sep 3, 2026
  12. hugovk
    added a commit that references this issue on Sep 5, 2026

    [3.15] gh-156347: Fix wrong statements in the curses documentation (G…

    996300c
  13. clin1234
    added a commit that references this issue on Sep 12, 2026

    pythongh-156347: Fix wrong statements in the curses documentation (py…

    a81d06a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-curses

Projects

  • Curses issues
    Status
    Done
    Show more project fields
  • docs issues
    Status
    Todo
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.