Distributes from pkg_resources.resource_string returns bytes under Python 3
Distributes from pkg_resources.resource_string returns bytes under Python 3, which is pretty surprising. :-) 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... Opinions on that?
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
On Sun, Mar 13, 2011 at 11:03, Ronald Oussoren <ronaldoussoren@mac.com> 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
participants (2)
-
Lennart Regebro -
Ronald Oussoren