From 5ff3f73d94305900c0773e67ebdd9701d856a0fe Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 19 Dec 2012 15:27:41 -0600 Subject: try to call __bytes__ before __index__ (closes #16722) --- Lib/test/test_bytes.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Lib/test/test_bytes.py') diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index fe6e93935b..f88c242922 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -701,6 +701,12 @@ class BytesTest(BaseBytesTest): 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): -- cgit v1.2.1