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 — Moving `_PyMem_RawStrdup` to private API causes build failure · Issue #127991 · python/cpython

Moving _PyMem_RawStrdup to private API causes build failure #127991

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Moving _PyMem_RawStrdup to private API causes build failure#127991
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-C-API

Description

@clin1234
clin1234
opened on Dec 16, 2024
Issue body actions

#106320 causes build failure in marcelotduarte/cx_Freeze#2568 (comment)

What is the recommended replacement for the now private function?

Activity

  1. tomasr8
    added
    topic-C-API
    on Dec 16, 2024
  2. tomasr8 commented on Dec 16, 2024

    @tomasr8
    tomasr8
    on Dec 16, 2024
    Member
    More actions

    Made private here: #107187

    I think as a replacement you can do what the function is doing internally, that is, call PyMem_RawMalloc and memcpy:

    cpython/Objects/obmalloc.c

    Lines 1047 to 1057 in 52d552c

    _PyMem_RawStrdup(const char *str)
    {
    assert(str != NULL);
    size_t size = strlen(str) + 1;
    char *copy = PyMem_RawMalloc(size);
    if (copy == NULL) {
    return NULL;
    }
    memcpy(copy, str, size);
    return copy;
    }

  3. ZeroIntensity commented on Dec 16, 2024

    @ZeroIntensity
    ZeroIntensity
    on Dec 16, 2024
    Member
    More actions

    @vstinner Do you think it's worth adding a public variation of PyMem_Strdup and PyMem_RawStrdup?

  4. vstinner commented on Dec 17, 2024

    @vstinner
    vstinner
    on Dec 17, 2024
    Member
    More actions

    @ZeroIntensity:

    @vstinner Do you think it's worth adding a public variation of PyMem_Strdup and PyMem_RawStrdup?

    It's not worth it. Please don't add them.

    There is a simple replacement for _PyMem_RawStrdup(): just use strdup() (with free()). If you really need/want to use PyMem_RawMalloc(), you can copy/paste the code that @tomasr8 gave.

    Reacted by Tomas R. and Peter Bierma
  5. clin1234
    added a commit that references this issue on Dec 17, 2024

    Replace _PyMem_RawStrdup with strdup

    5998cb0
  6. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Dec 17, 2024
  7. vstinner commented on Dec 17, 2024

    @vstinner
    vstinner
    on Dec 17, 2024
    Member
    More actions

    @clin1234: Would you be ok to close the issue? Or do you think that something else should be done? I'm not sure why you closed your cx_Freeze upstream PR.

  8. clin1234 commented on Dec 17, 2024

    @clin1234
    clin1234
    on Dec 17, 2024
    ContributorAuthor
    More actions

    I made a separate pull request replacing the private function with strdup (marcelotduarte/cx_Freeze#2738)

    Reacted by Victor Stinner
  9. clin1234
    closed this as completedon Dec 17, 2024
  10. ZeroIntensity
    closed this as not plannedon Dec 17, 2024
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-C-API

    Projects

    No projects

      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.