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 — PyUnicode_InternFromString does not immortalize the string as the document claims · Issue #133260 · python/cpython

PyUnicode_InternFromString does not immortalize the string as the document claims #133260

New issue
Copy link
New issue
Copy link
Closed
Closed
PyUnicode_InternFromString does not immortalize the string as the document claims#133260
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@yuyichao
yuyichao
opened on May 1, 2025
Issue body actions

Documentation

The document for PyUnicode_InternFromString currently claimed that

CPython implementation detail: Strings interned this way are made immortal.

However, testing with simple code like,

        auto v = PyUnicode_InternFromString("abcdefg_aaaaa");
        // PyUnicode_InternImmortal(&v);
        printf("immortalized? %d\n", _Py_IsImmortal(v));

suggests that the returned value is not, which is expected based on the code since it calls _PyUnicode_InternMortal rather than _PyUnicode_InternImmortal. If a call to the internal API PyUnicode_InternImmortal was added (as in the commented out code above), then the string is indeed immortalized.

This document was added in #121364 but that PR did not change the behavior of this function. AFAICT, PyUnicode_InternFromString never immortalize the string ever since it was added in #120520.

The only public API that ever immortalized the input string appears to be PyUnicode_InternInPlace and that was changed in #121364 (the one that added the wrong doc) and there doesn't seem to be any public API that immortalize the string anymore. Although this is technically a document issue, I think it might be better to change the behavior of the function instead to match the document.

Linked PRs

  • gh-133260: Remove claim that PyUnicode_InternFromString immortalizes #134213
  • [3.14] gh-133260: Remove claim that PyUnicode_InternFromString immortalizes (GH-134213) #134883
  • [3.13] gh-133260: Remove claim that PyUnicode_InternFromString immortalizes (GH-134213) #134884
Reacted by Kamil Monicz

Activity

  1. yuyichao
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on May 1, 2025
  2. github-project-automation
    added this to docs issueson May 1, 2025
  3. github-project-automation
    moved this to Todo in docs issueson May 1, 2025
  4. picnixz
    added
    topic-C-API
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    and removed
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on May 1, 2025
  5. picnixz commented on May 4, 2025

    @picnixz
    picnixz
    on May 4, 2025
    Member
    More actions

    Either it's a doc issue or it's an implementation issue. So I'll let both tags.

  6. picnixz
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on May 4, 2025
  7. neonene commented on May 5, 2025

    @neonene
    neonene
    on May 5, 2025
    Contributor
    More actions

    cc @encukou

  8. encukou
    added a commit that references this issue on May 19, 2025

    pythongh-133260: Remove claim that PyUnicode_InternFromString immorta…

    f99e8d1
  9. encukou commented on May 19, 2025

    @encukou
    encukou
    on May 19, 2025
    Member
    More actions

    Oh, good catch! Thanks! I did miss that in #121364 :/
    Given that 3.13 is in bugfix-only mode, I'll remove the docs note and backport that.

    @colesbury: PyUnicode_InternFromString can start immortalizing the string in main and possibly 3.14. Will it help free-threading?

  10. encukou
    added a commit that references this issue on May 29, 2025

    gh-133260: Remove claim that PyUnicode_InternFromString immortalizes (G…

    4109a9c
  11. miss-islington
    added 2 commits that reference this issue on May 29, 2025

    pythongh-133260: Remove claim that PyUnicode_InternFromString immorta…

    52f53f0

    pythongh-133260: Remove claim that PyUnicode_InternFromString immorta…

    17f74b4
  12. encukou
    added 2 commits that reference this issue on May 29, 2025

    [3.14] gh-133260: Remove claim that PyUnicode_InternFromString immort…

    2d40dd0

    [3.13] gh-133260: Remove claim that PyUnicode_InternFromString immort…

    a9ba2ec
  13. encukou commented on Jun 9, 2025

    @encukou
    encukou
    on Jun 9, 2025
    Member
    More actions

    The docs now allow either behaviour. Closing.
    Later we can make PyUnicode_InternFromString immortalize, if it's helpful.

    Thank you for the report, @yuyichao!

  14. encukou
    closed this as completedon Jun 9, 2025
  15. Pranjal095
    added a commit that references this issue on Jul 12, 2025

    pythongh-133260: Remove claim that PyUnicode_InternFromString immorta…

    defe241
  16. taegyunkim
    added a commit that references this issue on Aug 4, 2025

    pythongh-133260: Remove claim that PyUnicode_InternFromString immorta…

    a999247
  17. gostak-dd
    added a commit that references this issue on Jun 2, 2026

    pythongh-133260: Remove claim that PyUnicode_InternFromString immorta…

    c21e384
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

    docsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • 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 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.