Re: [Distutils] Distributes from pkg_resources.resource_string returns bytes under Python 3

2011-03-13 Thread Lennart Regebro
On Sun, Mar 13, 2011 at 11:03, Ronald Oussoren  wrote:
>
> On 13 Mar, 2011, at 9:52, Lennart Regebro wrote:
>
>> Distributes from pkg_resources.resource_string returns bytes under
>> Python 3, which is pretty surprising. :-)
>
> That's exactly what the documentation says it will return (the file is opened 
> in binary mode).  This is just one of many legacy APIs in Python libraries 
> where the naming is pretty lax w.r.t. bytes and text.

Sure, still surprising. I did however just now, when mentioning in
real life, realize that we could have a mode flag instead. Simpler and
backwards compatible.

//Lennart
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] Distributes from pkg_resources.resource_string returns bytes under Python 3

2011-03-13 Thread Ronald Oussoren

On 13 Mar, 2011, at 9:52, Lennart Regebro wrote:

> Distributes from pkg_resources.resource_string returns bytes under
> Python 3, which is pretty surprising. :-)

That's exactly what the documentation says it will return (the file is opened 
in binary mode).  This is just one of many legacy APIs in Python libraries 
where the naming is pretty lax w.r.t. bytes and text.

> Should we fix this? That would mean that we need to introduce a
> pkg_resources.resource_bytes that returns bytes under Python 3 and str
> (again) in Python 2. And probably we also need a
> pkg_resources.resource_unicode that returns Unicode under Python 2 and
> str under Python 3...

I wouldn't change this at this point in time, it is pretty likely that the 
change would break existing code. Making sure that distutils2 has the correct 
naming for their corresponding API would be fine though.

Ronald

> 
> 
> Opinions on that?
> ___
> Distutils-SIG maillist  -  Distutils-SIG@python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig