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
Fix comparison of plistlib.Data #70898
Comments
Proposed patch fixes several bugs in plistlib.Data.__eq__().
|
I don't understand the explicit use of __eq__ in the bytes case. Why is that needed? |
>>> import plistlib
>>> class MyData(bytes):
... def __eq__(self, other):
... if isinstance(other, plistlib.Data):
... return super().__eq__(other.value)
... return False
...
>>> plistlib.Data(b'x') == MyData(b'x')
True If use the equality operator the result is False. I don't know if this is good example. In any case this is corner case and we can manage with "==". |
Ronald, my second patch uses "==" instead of __eq__. Is it good to you? |
Serhiy, I slightly prefer the second patch, but either one would be fine. The reason I asked about explicitly calling __eq__ is that this is an uncommon pattern (at least for me). Ronald |
New changeset 41afb83cffac by Serhiy Storchaka in branch '3.5': New changeset dbdd5bc4df99 by Serhiy Storchaka in branch 'default': |
For simplicity I left "==" and fixed only obvious bug. |
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: