[Python-Dev] Re: python3 -bb and hash collisions

2019-09-13 Thread Cameron Simpson
On 13Sep2019 09:31, Matt Billenstein wrote: On Fri, Sep 13, 2019 at 08:37:26AM +1000, Cameron Simpson wrote: On 10Sep2019 10:42, Daniel Holth wrote: [...] > I stopped using Python 3 after learning about str(bytes) by finding it > in > my corrupted database. [...] Could you outline how this ha

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-13 Thread Matt Billenstein
On Fri, Sep 13, 2019 at 08:37:26AM +1000, Cameron Simpson wrote: > On 10Sep2019 10:42, Daniel Holth wrote: > [...] > > I stopped using Python 3 after learning about str(bytes) by finding it > > in > > my corrupted database. [...] > > Could you outline how this happened to you? Not the OP, but I'

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-12 Thread Nick Coghlan
On Fri., 13 Sep. 2019, 7:21 am Steven D'Aprano, wrote: > On Wed, Sep 11, 2019 at 09:34:07AM -0400, Daniel Holth wrote: > > > I didn't realize you could override __builtins__.str. That's interesting. > > Don't touch __builtins__ that's a CPython implementation detail. The > public API is to ``impo

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-12 Thread Cameron Simpson
On 10Sep2019 10:42, Daniel Holth wrote: [...] I stopped using Python 3 after learning about str(bytes) by finding it in my corrupted database. [...] Could you outline how this happened to you? Cheers, Cameron Simpson ___ Python-Dev mailing list --

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-12 Thread Steven D'Aprano
On Wed, Sep 11, 2019 at 09:34:07AM -0400, Daniel Holth wrote: > I didn't realize you could override __builtins__.str. That's interesting. Don't touch __builtins__ that's a CPython implementation detail. The public API is to ``import builtins`` and use that. This override technique is called mon

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-12 Thread Sebastian Rittau
Am 11.09.19 um 15:34 schrieb Daniel Holth: It's different. One hint is that there's already an option to disable the feature. The old style of error will occasionally reveal itself with decode errors but the new style error happens silently, you discover it somehow, then enable the -bb option

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-11 Thread Daniel Holth
On Tue, Sep 10, 2019 at 8:38 PM Matt Billenstein wrote: > On Tue, Sep 10, 2019 at 10:42:52AM -0400, Daniel Holth wrote: > > 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 > > lang

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-10 Thread Matt Billenstein
On Tue, Sep 10, 2019 at 10:42:52AM -0400, Daniel Holth wrote: > 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

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-10 Thread Eric V. Smith
On 9/10/2019 2:12 PM, Chris Angelico wrote: On Wed, Sep 11, 2019 at 12:47 AM Daniel Holth wrote: On Sat, Jun 22, 2019 at 2:48 AM Serhiy Storchaka 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 th

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-10 Thread Chris Angelico
On Wed, Sep 11, 2019 at 5:49 AM Ivan Pozdeev via Python-Dev wrote: > > On 10.09.2019 21:12, Chris Angelico wrote: > > On Wed, Sep 11, 2019 at 12:47 AM Daniel Holth wrote: > >> On Sat, Jun 22, 2019 at 2:48 AM Serhiy Storchaka > >> wrote: > >>> 22.06.19 01:08, Daniel Holth пише: > Thanks. I

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-10 Thread Ivan Pozdeev via Python-Dev
On 10.09.2019 21:12, Chris Angelico wrote: On Wed, Sep 11, 2019 at 12:47 AM Daniel Holth wrote: On Sat, Jun 22, 2019 at 2:48 AM Serhiy Storchaka 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 s

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-10 Thread Chris Angelico
On Wed, Sep 11, 2019 at 12:47 AM Daniel Holth wrote: > > On Sat, Jun 22, 2019 at 2:48 AM Serhiy Storchaka 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 c

[Python-Dev] Re: python3 -bb and hash collisions

2019-09-10 Thread Daniel Holth
On Sat, Jun 22, 2019 at 2:48 AM Serhiy Storchaka 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

[Python-Dev] Re: python3 -bb and hash collisions

2019-06-21 Thread Serhiy Storchaka
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

[Python-Dev] Re: python3 -bb and hash collisions

2019-06-21 Thread Daniel Holth
The answer bytes == str is just False. That doesn't put b'' in your database by accident. It could be useful to separate the two kinds of warnings. On Fri, Jun 21, 2019, 18:57 Ivan Pozdeev via Python-Dev < python-dev@python.org> wrote: > On 22.06.2019 1:08, Daniel Holth wrote: > > Thanks. I think

[Python-Dev] Re: python3 -bb and hash collisions

2019-06-21 Thread Ivan Pozdeev via Python-Dev
On 22.06.2019 1:08, Daniel Holth wrote: Thanks. I think I might like an option to disable str(bytes) without disabling str != bytes. Unless the second operation would also corrupt output. You can't compare str to bytes without knowing the encoding the bytes are supposed to be in (see https://s

[Python-Dev] Re: python3 -bb and hash collisions

2019-06-21 Thread 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. On Tue, Jun 18, 2019

[Python-Dev] Re: python3 -bb and hash collisions

2019-06-18 Thread Christian Heimes
On 18/06/2019 18.32, Daniel Holth wrote: > set([u"foo", b"foo]) will error because the two kinds of string have the > same hash, and this causes a comparison. Is that correct? Yes, it will fail with -bb, because it turns comparison between str and bytes into an error. This can also happen with oth