diff Lib/test/test_bytes.py @ 80954:c744b6f8a09a 3.3

try to call __bytes__ before __index__ (closes #16722)
author Benjamin Peterson <benjamin@python.org>
date Wed, 19 Dec 2012 15:27:41 -0600
parents 06577f6b1c99
children 55383912c225 7c717d423160
line wrap: on
line diff
--- a/Lib/test/test_bytes.py	Wed Dec 19 22:54:47 2012 +0200
+++ b/Lib/test/test_bytes.py	Wed Dec 19 15:27:41 2012 -0600
@@ -701,6 +701,12 @@
             def __bytes__(self):
                 return None
         self.assertRaises(TypeError, bytes, A())
+        class A:
+            def __bytes__(self):
+                return b'a'
+            def __index__(self):
+                return 42
+        self.assertEqual(bytes(A()), b'a')
 
     # Test PyBytes_FromFormat()
     def test_from_format(self):