]> granicus.if.org Git - python/commitdiff
Issue #26711: Fixed the comparison of plistlib.Data with other types.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 1 May 2016 10:36:16 +0000 (13:36 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 1 May 2016 10:36:16 +0000 (13:36 +0300)
Lib/plistlib.py
Lib/test/test_plistlib.py
Misc/NEWS

index a39151fb0beb7bcfa8da68f8e3934d7120e83a89..b66639ca9e59ea18a2cd1e19f9cbd8bbf4268144 100644 (file)
@@ -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))
index f0e9e5a9ea3dba182dd8219326f76568624f02ac..16114f9f6f3e4d6dd715697a418b2642d038d672 100644 (file)
@@ -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)
 
 
index 89403b04e89c74a6fcc21a94ef53e23fc36fe4cd..678fac1469ea6f6542cc1c745bda3a9bafc6d9ac 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -107,6 +107,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #26711: Fixed the comparison of plistlib.Data with other types.
+
 - Issue #24114: Fix an uninitialized variable in `ctypes.util`.
 
   The bug only occurs on SunOS when the ctypes implementation searches