Skip to content

LockedSet.__contains__ returns wrong value #3

Description

@xemage

The code in Chapter 5 - lockedSet.py doesn't work propperly.

If you create a LockedSet object i.e.

z = LockedSet({1, 2, 3, 4})

and check if 2 is in z it will fail.
2 in z
returns
False
z.__contains__(2)
returns
None

The solution is to return the result of super(LockedSet, self).__contains__(elem)

def __contains__(self, elem):
     with self._lock:`
          return super(LockedSet, self).__contains__(elem)

def __contains__(self, elem):

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions