[issue5964] WeakSet cmp methods

2009-05-07 Thread Robert Schuppenies
New submission from Robert Schuppenies : Running this code: >>> import weakref >>> class C: pass ... >>> ws = weakref.WeakSet([C]) >>> if ws == 1: ... print(1) ... gives me the following exception: Traceback (most recent call last): File "", line 1, in File "/home/bob/python/svn/py

[issue5964] WeakSet cmp methods

2009-05-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't think it is the intended behaviour. Comparison for equality should return either True or False (or perhaps NotImplemented?), not raise a TypeError. -- nosy: +pitrou priority: -> normal stage: -> needs patch ___

[issue5964] WeakSet cmp methods

2009-05-10 Thread Robert Schuppenies
Robert Schuppenies added the comment: Here is a patch which will return False instead of TypeError. This is the same behavior a normal set has. Two things though. 1. I don't know wether the 'import _abcoll' statement somehow influences the bootstrap in one way or the other, because 'from _abcol

[issue5964] WeakSet cmp methods

2009-05-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: > 2. The current WeakSet implementation returns True if a WeakSet is > compared to any Iterable which contains the same set of objects: Sounds bad. It should probably be fixed. -- ___ Python tracker

[issue5964] WeakSet cmp methods

2009-05-11 Thread Robert Schuppenies
Robert Schuppenies added the comment: Sounds right to me. Here is another patch plus tests. Going through the other tests, I adapted two more tests to actually test WeakSet. Also, I found the following one and think it is a copy&paste from test_set which is not useful for test_weakset. Should i

[issue5964] WeakSet cmp methods

2009-05-11 Thread Robert Schuppenies
Changes by Robert Schuppenies : Removed file: http://bugs.python.org/file13955/_weakrefset.patch ___ Python tracker ___ ___ Python-bugs-list ma

[issue5964] WeakSet cmp methods

2009-05-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Going through the other tests, I adapted two more tests to actually test > WeakSet. Also, I found the following one and think it is a copy&paste > from test_set which is not useful for test_weakset. Should it be removed > (as currently done in the patch)? Abs

[issue5964] WeakSet cmp methods

2009-05-12 Thread Robert Schuppenies
Changes by Robert Schuppenies : -- stage: needs patch -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue5964] WeakSet cmp methods

2009-05-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Is the current patch ready for consumption? -- ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue5964] WeakSet cmp methods

2009-05-14 Thread Robert Schuppenies
Robert Schuppenies added the comment: The test passes on my machine, but a quick review would definitely be nice :) -- ___ Python tracker ___

[issue5964] WeakSet cmp methods

2009-05-14 Thread Robert Schuppenies
Robert Schuppenies added the comment: If that is the right behavior then yes. Is this documented somewhere? -- ___ Python tracker ___

[issue5964] WeakSet cmp methods

2009-05-14 Thread Benjamin Peterson
Benjamin Peterson added the comment: See http://docs.python.org/reference/datamodel.html#object.__eq__ -- nosy: +benjamin.peterson ___ Python tracker ___

[issue5964] WeakSet cmp methods

2009-05-14 Thread Robert Schuppenies
Robert Schuppenies added the comment: I am now a bit confused about the semantics of __eq__ for WeakSets. Is a WeakSet only equal to another WeakSet with the same elements or to any iterable with the same elements, e.g. list? Because this is how I read the current implementation. If it is the la

[issue5964] WeakSet cmp methods

2009-05-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: Why are you confused? You already asked that question earlier in the thread. -- ___ Python tracker ___ _

[issue5964] WeakSet cmp methods

2009-05-15 Thread Robert Schuppenies
Robert Schuppenies added the comment: Maybe because I take the doc too specfic. It says "A rich comparison method may return the singleton NotImplemented if it does not implement the operation for a given pair of arguments." I see the type check of the 'other' object as an operation towards the

[issue5964] WeakSet cmp methods

2009-05-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I see the type check of the 'other' object as an operation towards the > equal comparison, since it validates wether 'self' and 'other' can be > equal at all. If they are of a different type, then they cannot be > equal, thus the anwser to "Are 'self' and 'oth

[issue5964] WeakSet cmp methods

2009-05-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: You can commit the latest patch, provided all tests pass. -- assignee: -> schuppenies resolution: -> accepted stage: patch review -> commit review ___ Python tracker

[issue5964] WeakSet cmp methods

2009-05-17 Thread Robert Schuppenies
Robert Schuppenies added the comment: Fixed in r72751. -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue5964] WeakSet cmp methods

2009-05-18 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- resolution: accepted -> fixed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt