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 — Use `frozendict` in Lib/curses/has_key.py · Issue #146153 · python/cpython

Use frozendict in Lib/curses/has_key.py #146153

New issue
Copy link
New issue
Copy link
Closed
#146154
Closed
Use frozendict in Lib/curses/has_key.py#146153
#146154
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@jonathandung
jonathandung
opened on Mar 19, 2026
Issue body actions

Feature or enhancement

Proposal:

The pure python implementation of curses.has_key makes use of the has_key sub-module, which has seen no update in 20 years. Now that the frozendict built-in type has been implemented, the _capability_names dict there can be converted into a frozendict.

This dict is supposed to map curses keys to terminfo capability names, and seeing as though its name begins with an underscore, it should be considered an implementation detail anyway. No code modifies this dict, the contents of which are only used by the has_key function here:

def has_key(ch):
    if isinstance(ch, str):
        ch = ord(ch)

    # Figure out the correct capability name for the keycode.
    capability_name = _capability_names.get(ch)
    if capability_name is None:
        return False

This is a very prime example of a use case of frozendict. I will open a PR to close this.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-146153: Use frozendict in pure python fallback for curses.has_key #146154

Activity

  1. jonathandung
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Mar 19, 2026
  2. jonathandung
    changed the title [-]Use `frozenmap` in Lib/curses/has_key.py[/-] [+]Use `frozendict` in Lib/curses/has_key.py[/+] on Mar 19, 2026
  3. aisk
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Mar 19, 2026
  4. aisk
    added this to Curses issueson Mar 19, 2026
  5. vstinner
    added a commit that references this issue on Mar 21, 2026

    gh-146153: Use `frozendict` in pure python fallback for `curses.has_k…

    f6b5eed
  6. vstinner
    closed this as completedin #146154on Mar 21, 2026
  7. github-project-automation
    moved this to Done in Curses issueson Mar 21, 2026
  8. CuriousLearner
    added a commit that references this issue on Mar 22, 2026

    Merge remote-tracking branch 'upstream/main' into fix-pythongh-138577

    2691ad9
  9. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-146153: Use `frozendict` in pure python fallback for `curses…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Curses issues
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — 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.