Issue #26711: Fixed the comparison of plistlib.Data with other types.
This commit is contained in:
parent
f5f37d784b
commit
dd1bcdf618
|
@ -225,10 +225,10 @@ class Data:
|
|||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return self.data == other.data
|
||||
elif isinstance(other, str):
|
||||
elif isinstance(other, bytes):
|
||||
return self.data == other
|
||||
else:
|
||||
return id(self) == id(other)
|
||||
return NotImplemented
|
||||
|
||||
def __repr__(self):
|
||||
return "%s(%s)" % (self.__class__.__name__, repr(self.data))
|
||||
|
|
|
@ -515,15 +515,15 @@ class TestPlistlibDeprecated(unittest.TestCase):
|
|||
|
||||
cur = plistlib.loads(buf)
|
||||
self.assertEqual(cur, out_data)
|
||||
self.assertNotEqual(cur, in_data)
|
||||
self.assertEqual(cur, in_data)
|
||||
|
||||
cur = plistlib.loads(buf, use_builtin_types=False)
|
||||
self.assertNotEqual(cur, out_data)
|
||||
self.assertEqual(cur, out_data)
|
||||
self.assertEqual(cur, in_data)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
cur = plistlib.readPlistFromBytes(buf)
|
||||
self.assertNotEqual(cur, out_data)
|
||||
self.assertEqual(cur, out_data)
|
||||
self.assertEqual(cur, in_data)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue