Skip to content

Commit b4b1a34

Browse files
Issue #26711: Fixed the comparison of plistlib.Data with other types.
1 parent fe0a360 commit b4b1a34

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

Lib/plistlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ def asBase64(self, maxlinelength=76):
225225
def __eq__(self, other):
226226
if isinstance(other, self.__class__):
227227
return self.data == other.data
228-
elif isinstance(other, str):
228+
elif isinstance(other, bytes):
229229
return self.data == other
230230
else:
231-
return id(self) == id(other)
231+
return NotImplemented
232232

233233
def __repr__(self):
234234
return "%s(%s)" % (self.__class__.__name__, repr(self.data))

Lib/test/test_plistlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,15 +515,15 @@ def test_dataobject_deprecated(self):
515515

516516
cur = plistlib.loads(buf)
517517
self.assertEqual(cur, out_data)
518-
self.assertNotEqual(cur, in_data)
518+
self.assertEqual(cur, in_data)
519519

520520
cur = plistlib.loads(buf, use_builtin_types=False)
521-
self.assertNotEqual(cur, out_data)
521+
self.assertEqual(cur, out_data)
522522
self.assertEqual(cur, in_data)
523523

524524
with self.assertWarns(DeprecationWarning):
525525
cur = plistlib.readPlistFromBytes(buf)
526-
self.assertNotEqual(cur, out_data)
526+
self.assertEqual(cur, out_data)
527527
self.assertEqual(cur, in_data)
528528

529529

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Core and Builtins
107107
Library
108108
-------
109109

110+
- Issue #26711: Fixed the comparison of plistlib.Data with other types.
111+
110112
- Issue #24114: Fix an uninitialized variable in `ctypes.util`.
111113

112114
The bug only occurs on SunOS when the ctypes implementation searches

0 commit comments

Comments
 (0)