Skip to content

Fix contains unexpected false return #13

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

Closed
wants to merge 4 commits into from
Closed

Fix contains unexpected false return #13

wants to merge 4 commits into from

Conversation

thekafkaf
Copy link
Contributor

In my opinion, contains should return true when used on the same object

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling eb25626 on thekafkaf:fix-contains-unexpected-false-return into 490c7a2 on stefankoegl:master.

@@ -249,7 +249,7 @@ def walk(self, doc, part):

def contains(self, ptr):
""" Returns True if self contains the given ptr """
return len(self.parts) > len(ptr.parts) and \
return len(self.parts) >= len(ptr.parts) and \
self.parts[:len(ptr.parts)] == ptr.parts
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make sense, and would be consistent with the behaviour of stdlib types. I think that then we could reduce the implementation of contains to just self.parts[:len(ptr.parts)] == ptr.parts (and remove the first line of the return completely).

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 1655783 on thekafkaf:fix-contains-unexpected-false-return into 490c7a2 on stefankoegl:master.

@stefankoegl
Copy link
Owner

Squashed and merged in d3966dd. Thanks :)

@stefankoegl
Copy link
Owner

I've just released jsonpointer 1.6 containing this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants