Skip to content

Commit 1135390

Browse files
committed
Fix tests
1 parent be56685 commit 1135390

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Objects/bytesobject.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,12 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
25492549
}
25502550

25512551
/* This overestimates if there are spaces */
2552-
writer = _PyBytesWriter_CreateByteArray(hexlen / 2);
2552+
if (use_bytearray) {
2553+
writer = _PyBytesWriter_CreateByteArray(hexlen / 2);
2554+
}
2555+
else {
2556+
writer = PyBytesWriter_Create(hexlen / 2);
2557+
}
25532558
if (writer == NULL) {
25542559
goto release_buffer;
25552560
}
@@ -3736,6 +3741,9 @@ byteswriter_data(PyBytesWriter *writer)
37363741
if (writer->obj == NULL) {
37373742
return writer->small_buffer;
37383743
}
3744+
else if (writer->use_bytearray) {
3745+
return PyByteArray_AS_STRING(writer->obj);
3746+
}
37393747
else {
37403748
return PyBytes_AS_STRING(writer->obj);
37413749
}

0 commit comments

Comments
 (0)