We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be56685 commit 1135390Copy full SHA for 1135390
1 file changed
Objects/bytesobject.c
@@ -2549,7 +2549,12 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
2549
}
2550
2551
/* This overestimates if there are spaces */
2552
- writer = _PyBytesWriter_CreateByteArray(hexlen / 2);
+ if (use_bytearray) {
2553
+ writer = _PyBytesWriter_CreateByteArray(hexlen / 2);
2554
+ }
2555
+ else {
2556
+ writer = PyBytesWriter_Create(hexlen / 2);
2557
2558
if (writer == NULL) {
2559
goto release_buffer;
2560
@@ -3736,6 +3741,9 @@ byteswriter_data(PyBytesWriter *writer)
3736
3741
if (writer->obj == NULL) {
3737
3742
return writer->small_buffer;
3738
3743
3744
+ else if (writer->use_bytearray) {
3745
+ return PyByteArray_AS_STRING(writer->obj);
3746
3739
3747
else {
3740
3748
return PyBytes_AS_STRING(writer->obj);
3749
0 commit comments