New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review all use of byte literals #1850
Comments
Here's an annotated grep for all byte literals in /mopidy, generated from looks to me like there are only two problems, in i've assumed that anything that works on data from a network or disk is working on raw bytes. all my notes below.
|
Thank you for the review! I agree that passing bytes to I think we might want to try changing |
On Sun, Dec 08, 2019 at 01:02:42PM -0800, Stein Magnus Jodal wrote:
I agree that passing bytes to `xml.etree` is probably wrong.
Well-formed XML documents always have an encoding defined, so I would
these are special string constants, not anything from the document, as
far as i can tell.
think that `xml.etree` should work well if we use text throughout our
interactions with it.
I think we might want to try changing `ConfigValue.serialize()` to
return text. I think I left a comment on that in the source while
porting to Python 3.
I think a serialisation format should return what actually gets put on
the disk, not python's intermediate string format. keep it bytes!
|
The config value's own `encode()` method ensures that we use the `surrogateescape` error handler, so that all bytes will survive the conversion to text and back to bytes. With this rewrite, only the `encode()` function and the two places that outputs the config document, either to file or console, have to care about "surrogateescape". Everything else is just concerned with text. Fixes mopidy#1850 (partly)
Before the final release of Mopidy 3 we should review all use of byte literals (
b'foobar'
). Most of these are probably remnants from Python 2 and are now likely sources of bugs.The text was updated successfully, but these errors were encountered: