Skip to content

[C API] Add PyBytes_Join() function #121645

Description

@vstinner

Feature or enhancement

Python 3.13 alpha 1 removed the private _PyBytes_Join(sep, iterable) function which calls sep.join(iterable).

mypyc uses it. Since we already have PyUnicode_Join(sep, iterable), I propose to add a new PyBytes_Join() function.

In practice, it's just about renaming _PyBytes_Join() to PyBytes_Join().

Linked PRs

Activity

  1. added 2 commits that reference this issue on Jul 12, 2024
  2. vstinner commented on Jul 12, 2024

    @vstinner
    MemberAuthor

    mypyc uses it.

    A code search on PyPI top 7,500 projects found 6 projects using the private _PyBytes_Join() function:

    • Cython (3.0.9)
    • dbnd (1.0.22.9)
    • dulwich (0.21.7)
    • mod_wsgi (5.0.0)
    • mpi4py (3.1.5)
    • mypy (1.9.0)
  3. vstinner commented on Jul 12, 2024

    @vstinner
    MemberAuthor

    mypyc uses it

    Sorry, I forgot to add a reference to the mypy issue: issue gh-121489.

  4. ZeroIntensity commented on Jul 12, 2024

    @ZeroIntensity
    Member

    Additionally, many repositories use _PyBytes_Resize as well. Perhaps that's something that should go public?

  5. vstinner commented on Jul 13, 2024

    @vstinner
    MemberAuthor

    Additionally, many repositories use _PyBytes_Resize as well. Perhaps that's something that should go public?

    IMO _PyBytes_Resize() is a bad pattern, it uses a bytes object which is incomplete/inconsistent: see capi-workgroup/api-evolution#36.

    Instead, I created #121710: [C API] Add PyBytesWriter API.

  6. added 2 commits that reference this issue on Aug 27, 2024
  7. vstinner commented on Aug 30, 2024

    @vstinner
    MemberAuthor

    Implemented by the change 3d60dfb.

  8. added 2 commits that reference this issue on Sep 6, 2024
  9. i-l-s-h-a-t commented on Nov 10, 2025

    @i-l-s-h-a-t

    Dear @vstinner,

    I have an issue during my Python wheel generation on Linux, Python 3.13:

          ../numpy/_core/src/common/pythoncapi-compat/pythoncapi_compat.h: In function ‘PyObject* PyBytes_Join(PyObject*, PyObject*)’:
          ../numpy/_core/src/common/pythoncapi-compat/pythoncapi_compat.h:1607:12: error: ‘_PyBytes_Join’ was not declared in this scope; did you mean ‘PyBytes_Join’?
    

    My code has numpy dependency and it uses pybind11 C++ library. I would like then to generate a wheel for it.

    Could it be due to this renaming?
    There is a check here but it checks only Python 3.14, and not 3.13:

    Image

    I see there is a backward compatibility was assumed

    Image

    As you can see it doesn't work in my case.

    The whole log is here https://pastebin.com/Am07UcZg
    I have this issue only for Python 3.13, only on Linux (docker image python:3.13). I tried to just install numpy and that works there. Looks like for my wheel creation, it does something else which fails.
    And there is no such an issue on other Python versions (3.12 or 3.14) and Windows (Python 3.10-3.14).

    I will appreciate you help.

    Best,
    ilshat

  10. vstinner commented on Nov 10, 2025

    @vstinner
    MemberAuthor

    @i-l-s-h-a-t: Interesting bug. It's unrelated to Python, so can you please open an issue at https://github.com/python/pythoncapi-compat/issues? Please include commands on how to reproduce your issue.

  11. i-l-s-h-a-t commented on Nov 11, 2025

    @i-l-s-h-a-t

    @i-l-s-h-a-t: Interesting bug. It's unrelated to Python, so can you please open an issue at https://github.com/python/pythoncapi-compat/issues? Please include commands on how to reproduce your issue.

    @vstinner Thank you for your reply. I created an issue there.
    Although I could not reproduce the issue locally which appears in gitlab CI/CD.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions