mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #26766: Fix _PyBytesWriter_Finish()
Return a bytearray object when bytearray is requested and when the small buffer is used. Fix also test_bytes: bytearray%args must return a bytearray type.
This commit is contained in:
parent
12bb6f4c7d
commit
e914d41312
2 changed files with 8 additions and 3 deletions
|
@ -4150,7 +4150,12 @@ _PyBytesWriter_Finish(_PyBytesWriter *writer, void *str)
|
|||
result = PyBytes_FromStringAndSize(NULL, 0);
|
||||
}
|
||||
else if (writer->use_small_buffer) {
|
||||
result = PyBytes_FromStringAndSize(writer->small_buffer, size);
|
||||
if (writer->use_bytearray) {
|
||||
result = PyByteArray_FromStringAndSize(writer->small_buffer, size);
|
||||
}
|
||||
else {
|
||||
result = PyBytes_FromStringAndSize(writer->small_buffer, size);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = writer->buffer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue