diff options
author | Victor Stinner <vstinner@python.org> | 2024-08-30 12:57:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 12:57:33 (GMT) |
commit | 3d60dfbe1755e00ab20d0ee81281886be77ad5da (patch) | |
tree | b1078f50a6b8641321f1044698867cb52f27105e /Objects | |
parent | 7fca268beee8ed13a8f161f0a0d5e21ff52d1ac1 (diff) | |
download | cpython-3d60dfbe1755e00ab20d0ee81281886be77ad5da.zip cpython-3d60dfbe1755e00ab20d0ee81281886be77ad5da.tar.gz cpython-3d60dfbe1755e00ab20d0ee81281886be77ad5da.tar.bz2 |
gh-121645: Add PyBytes_Join() function (#121646)
* Replace _PyBytes_Join() with PyBytes_Join().
* Keep _PyBytes_Join() as an alias to PyBytes_Join().
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index e88b199..c467b24 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1867,11 +1867,19 @@ bytes_join(PyBytesObject *self, PyObject *iterable_of_bytes) } PyObject * -_PyBytes_Join(PyObject *sep, PyObject *x) +PyBytes_Join(PyObject *sep, PyObject *iterable) { - assert(sep != NULL && PyBytes_Check(sep)); - assert(x != NULL); - return bytes_join((PyBytesObject*)sep, x); + if (sep == NULL) { + PyErr_BadInternalCall(); + return NULL; + } + if (!PyBytes_Check(sep)) { + PyErr_Format(PyExc_TypeError, + "sep: expected bytes, got %T", sep); + return NULL; + } + + return stringlib_bytes_join(sep, iterable); } /*[clinic input] |