On 11 September 2014 16:47, Chris Lasher firstname.lastname@example.org wrote:
You passed bytes – not an ASCII string – as an argument to os.listdir; it gave you back bytes, not ASCII strings. You _consented_ to bytes when you put the b'Mac' in there; therefore, you are responsible for decoding those bytes.
Yes, all text must be represented an bytes to a computer, but not all bytes represent text.
Yes, we know. We debated this 8 years ago. We *tried it* 8 years ago. We found it to provide a horrible developer experience, so we changed it back to be closer to the way Python 2 works. Changing the default representation of binary data to something that we already decided didn't work (or at least its very close cousin) is not up for discussion.
Providing better tools for easily producing hexadecimal representations is an excellent idea. Making developers explicitly request non-horrible output when working with binary APIs on POSIX systems is not.
You can keep saying "but it's potentially confusing when it really is arbitrary binary data", and I'm telling you *that doesn't matter*. The consequences of flipping the default are worse, because it means defaulting to unreadable output from supported operating system interfaces, which *will* leak through to API consumers and potentially even end users. That's not OK, which means the status quo is the lesser of two evils.