New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_weakrefset.WeakSet.__contains__ should not propagate TypeErrors #54569
Comments
Because application code which tests for the presence of Patch forthcoming. |
A result from IRC is that to be consistent with normal sets, only TypeErrors coming from ref() should be caught, but not those TypeErrors from the actual membership test (i.e. the hash functioon of the value). |
A new version of the patch, which only traps TypeErrors raises |
"One more time, with feeling." Sorry for the noise, the last patch was not against the 2.7 trunk. |
FTR, the patch applies cleanly to the py3k branch, too. (Michael |
What is the behaviour of WeakKeyDictionary here? I don't really agree that TypeError should be silenced. |
WeakKeyDictionary's __contains__: def __contains__(self, key):
try:
wr = ref(key)
except TypeError:
return 0
return wr in self.data |
I don't have any other insights on this one. Assigned by to Antoine who appears to have put some thought into it. |
Well if WeakKeyDictionary silences the TypeError from ref(), it sounds consistent for WeakSet to silence it too. |
I agree; committed in r86960. If anyone wants to change this to raise TypeError for objects that are both unhashable and unrefable, please speak up. |
This fix needs backporting to the 3.1 and 2.7 branches as well. |
Don't worry, it will be ported. |
georg.brandl (2010-12-03 10:20):
When? Why would it *not* be merged to the 2.7 and 3.1 branches at the In particular, I would like confirmation that the fix *will* be ported |
Let's reopen until then. |
Because I don't think porting every change immediately is worth my time when I can do it much faster in mass-merges. I know other developers do this differently, but since I use svnmerge to do my mass-merges, there won't be any falling through cracks. |
Backported to 3.1 in r88556, and 2.7 in r88564. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: