[Python-Dev] pathlib - current status of discussions

Ethan Furman ethan at stoneleaf.us
Thu Apr 14 14:17:25 EDT 2016


On 04/14/2016 10:22 AM, Paul Moore wrote:
> On 14 April 2016 at 17:46, Ethan Furman wrote:

>> If you are not working at the bytes layer, you shouldn't be getting bytes
>> objects because:
>>
>> - you specified str when asking for data from the OS, or
>> - you transformed the incoming bytes from whatever external source
>>    to str when you received them.
>
> My experience is that (particularly with code that was originally
> written for Python 2) "you have control of your data" is often an
> illusion - bytes can appear in code from unexpected sources, and when
> they do I'd rather see an error if I'm using code where I expect a
> string. Certainly that's a bug in the code - all I'm saying is that it
> fail early rather than late.

If we have one function that uses a flag and you leave the flag alone 
(it defaults to rejecting bytes) -- voila!  An error is raised when 
bytes show up.

> I'd appreciate it if anyone can clarify why "gracefully extending" the
> protocol to include bytes support at a later date isn't practical.

It's going to be a bunch of work.  I don't want to do the work twice.

On the other hand, if while doing the work it becomes apparent that 
supporting bytes and str in the protocol is either infeasible, 
confusing, or a plain ol' bad idea I have no problem ripping out the 
bytes support and going to str only.

--
~Ethan~



More information about the Python-Dev mailing list