2 ms·
`bytes` is plainly special case for historical reasons here - it's something that is not a string, but that so many people assume to be a string. So yeah, I wo
by int_19h 10y ago
`bytes` is plainly special case for historical reasons here - it's something that is not a string, but that so many people assume to be a string.
So yeah, I would be fine with making an exception for it (and providing some kind of option to disable that exception, for that incredibly rare case where someone really does need b"foo" in their CSV output).
And then in 5 years, flip the default of that switch, and deprecate it. In another 5, remove it entirely.
Also, note that raising an error in this case is not placating the people who insist on using bytes as strings. Quite the opposite - it very loudly and unambiguously tells them that they're wrong, and how exactly they're wrong.
- ubernostrum 10y agoThe entire problem, though, is people assuming bytes and strings are interchangeable. Anything which allows that assumption to go unquestioned, or without program-wrecking consequences, leads right back to where we were. And the "phase it out" model doesn't work; you proposed a ten-year phase-out, but in ten years people are just going to say "we never updated our code, we're not ready, keep it this way another ten years and we'll think about fixing our code". The only thing that works is actively breaking people's programs when they try to intermix bytes and strings.
- int_19h 10y ago> The only thing that works is actively breaking people's programs when they try to intermix bytes and strings. Um, this is exactly what I proposed above! "this should be a hard error, immediately reported as such, and not just a silent behavior change." What I'm asking for is that csv writer raises an exception if it sees bytes anywhere by default. The problem is that right now, it doesn't! It just gives you "incorrect" output, that might go undetected for a long time.