[issue45605] Return False from __contains__ method if object not hashable for set and dict

2021-10-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This is a duplicate of issue18510. It was also discussed on the Python-Dev 
mailing list (maybe more than once). If you have some new arguments or 
something in past 8 years made the old arguments no longer valid please open a 
new discussion on the mailing list.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> dict.__contains__ and dict.keys().__contains__ raises exception 
instead of returning False

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45605] Return False from __contains__ method if object not hashable for set and dict

2021-10-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't have any code that would care, but if there's one thing I've learned in 
15 years of python core development, it's that this will break someone's code.

If you want more feedback, you should probably bring this up for discussion on 
the python-ideas mailing list.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45605] Return False from __contains__ method if object not hashable for set and dict

2021-10-25 Thread Андрей Казанцев

Андрей Казанцев  added the comment:

Can you please specify in what cases we need to get an exception instead of 
False? It just seems very strange to me to rely on this behaviour.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45605] Return False from __contains__ method if object not hashable for set and dict

2021-10-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

That seems like a pretty big change that could break a lot of existing code. I 
suggest writing a wrapper around "in" if you want this behavior.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45605] Return False from __contains__ method if object not hashable for set and dict

2021-10-25 Thread Андрей Казанцев

New submission from Андрей Казанцев :

Now if do something like `[] in set()` python raise an exception, but if an 
object isn't hashable then we know for sure that it isn't in the set. Propose 
return False for these cases.

P.S. I would like to make a patch

--
components: Library (Lib)
messages: 404971
nosy: heckad
priority: normal
severity: normal
status: open
title: Return False from __contains__ method if object not hashable for set and 
dict
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com