Repository navigation
[C API] Add PyBytes_Join() function #121645
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Jul 12, 2024 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)
mypyc uses it
Sorry, I forgot to add a reference to the mypy issue: issue gh-121489.
Additionally, many repositories use
_PyBytes_Resizeas well. Perhaps that's something that should go public?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.
Reacted by Peter BiermaImplemented by the change 3d60dfb.
- added a commit that references this issue
on Oct 14, 2024 - added a commit that references this issue
on Oct 14, 2024 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:
I see there is a backward compatibility was assumed
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@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.
@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.
Feature or enhancement
Python 3.13 alpha 1 removed the private
_PyBytes_Join(sep, iterable)function which callssep.join(iterable).mypyc uses it. Since we already have
PyUnicode_Join(sep, iterable), I propose to add a newPyBytes_Join()function.In practice, it's just about renaming
_PyBytes_Join()toPyBytes_Join().Linked PRs