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

Ronald Oussoren ronaldoussoren at mac.com
Sun Mar 13 16:03:36 CET 2011


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 at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig



More information about the Distutils-SIG mailing list