Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

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

Description

@yuyichao

Documentation

The document forPyUnicode_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 APIPyUnicode_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 bePyUnicode_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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp