[Python-Dev] Pathlib enhancements - improve fsdecode and fsencode (original) (raw)

Stephen J. Turnbull stephen at xemacs.org
Thu Apr 14 02:55:49 EDT 2016


Please please please, junk both "filter out bytes" proposals.

Since they involve an exception, they impose an unnecessary "try" on all text applications that fear death on bytes returns. May as well just wrap all objects with fspath in fsdecode, and all is happy.

Counterproposal: make fsdecode and fsencode grok fspath. Then: (1) Bytes-lovers and str-addicts are both safe. (2) They can omit fspath, too!

No, that doesn't work if the bytes objects aren't in the file system encoding, but these are bytes, mon ami: you have no way to find out what that encoding is, so you either know already and you substitute that + fspath for fsdecode, or you're hosed. And in the only concrete use case so far, fsdecode Just Works.

I suppose a similar argument holds for applications that want bytes and fsencode, but I leave that as an exercise for the reader.



More information about the Python-Dev mailing list