Closed khaledhosny closed 6 years ago
that's wrong, indeed. It should be changed to tobytes(data, encoding=encoding)
However, if the method is called writeBytesToPath
, it would also be correct to expect that data
is of type bytes already and raise if it isn't, passing responsibility of encoding it to the caller.
@khaledhosny can you send a PR?
UFOWriter.writeBytesToPath
doesn't have an encoding
argument any more, because it didn't make any sense. The method says "write bytes" so the user should pass a string of type bytes
. If it were named "write text" then the encoding
argument would have made sense: it would mean, use this encoding to convert some text (a unicode string) to bytes when writing the file.
it's the same reason that built-in open
function doesn't accept an encoding
parameter when the mode is wb
.
The following code:
Fails with the following error: