On 9/10/2019 2:12 PM, Chris Angelico wrote:
On Wed, Sep 11, 2019 at 12:47 AM Daniel Holth <dho...@gmail.com> wrote:

On Sat, Jun 22, 2019 at 2:48 AM Serhiy Storchaka <storch...@gmail.com> wrote:

22.06.19 01:08, Daniel Holth пише:
Thanks. I think I might like an option to disable str(bytes) without
disabling str != bytes. Unless the second operation would also corrupt
output.

Came across this kind of set in the hyper http library which uses a set
to accept certain headers with either str or bytes keys.

Does that library support Python 2?  If it is true than you have a
problem, because u'abc' == b'abc' in Python 2 and u'abc' != b'abc' in
Python 3.

If it is Python 3 only, you can just ignore BytesWarning. It was added
purely to help to catch subtle bugs in transition to Python 3. In
future, after Python 2 be out of use, BytesWarning will become deprecated.


I stopped using Python 3 after learning about str(bytes) by finding it in my 
corrupted database. Ever since then I've been anxious about changing to the new 
language, since it makes it so easy to convert from bytes to unicode by 
accident without specifying a valid encoding. So I would like to see a future 
where str(bytes) is effectively removed. I started working on a pull request 
that adds an API to toggle str(bytes) at runtime with a thread local (instead 
of requiring a command line argument), so you could do with no_str_bytes(): if 
you were worried about the feature, but got a bit stuck in the internals.


Python has, for as long as I've known it, permitted you to call str()
on literally any object - if there's no other string form, you get its
repr. Breaking this would break all manner of debugging techniques.

Right. Think of print(bytes).

Eric
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/GZ47OO2TNB3MOJ72W2F2R3A7JNFGHL6N/

Reply via email to