[New-bugs-announce] [issue26711] Fix comparison of plistlib.Data

Serhiy Storchaka report at bugs.python.org
Thu Apr 7 16:06:42 EDT 2016


New submission from Serhiy Storchaka:

Proposed patch fixes several bugs in plistlib.Data.__eq__().

* isinstance(other, str) was used instead of isinstance(other, bytes). Data always wraps bytes and should be comparable with bytes. str was correct type in Python 2.

* id(self) == id(other) is always false, because if other is self, the first condition (isinstance(other, self.__class__)) should be true. NotImplemented should be returned as fallback. This allows comparing with Data subclasses and correct work of __ne__().

* The __eq__() method should be used instead of the equality operator. This is needed for correct work in case if value is bytes subclass with overloaded __eq__().

----------
components: Library (Lib)
files: plistlib_data_eq.patch
keywords: patch
messages: 263001
nosy: ronaldoussoren, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Fix comparison of plistlib.Data
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42394/plistlib_data_eq.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26711>
_______________________________________


More information about the New-bugs-announce mailing list