Skip to content

Commit 6217bd6

Browse files
committed
Sync bytesobject.c with CPython
1 parent 36c44b0 commit 6217bd6

File tree

3 files changed

+3161
-240
lines changed

3 files changed

+3161
-240
lines changed

graalpython/com.oracle.graal.python.cext/src/bytearrayobject.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,14 @@ void bytearray_releasebuffer(PyByteArrayObject *obj, Py_buffer *view) {
6464
Py_ssize_t PyByteArray_Size(PyObject *self) {
6565
return PyByteArray_GET_SIZE(self);
6666
}
67+
68+
PyObject* PyByteArray_FromStringAndSize(const char* str, Py_ssize_t sz) {
69+
if (sz < 0) {
70+
PyErr_SetString(PyExc_SystemError, "Negative size passed to PyByteArray_FromStringAndSize");
71+
return NULL;
72+
}
73+
if (str != NULL) {
74+
return GraalPyTruffleByteArray_FromStringAndSize(str, sz);
75+
}
76+
return GraalPyTruffle_ByteArray_EmptyWithCapacity(sz);
77+
}

0 commit comments

Comments
 (0)