diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-12-19 21:27:41 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-12-19 21:27:41 (GMT) |
commit | 5ff3f73d94305900c0773e67ebdd9701d856a0fe (patch) | |
tree | 2d63f3211ab3419a020f71fd081ff6d02cf9d7e2 /Lib/test/test_bytes.py | |
parent | 1f415cf2c2b5f3eec5489ec1276c0629b32b28c0 (diff) | |
download | cpython-5ff3f73d94305900c0773e67ebdd9701d856a0fe.zip cpython-5ff3f73d94305900c0773e67ebdd9701d856a0fe.tar.gz cpython-5ff3f73d94305900c0773e67ebdd9701d856a0fe.tar.bz2 |
try to call __bytes__ before __index__ (closes #16722)
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index fe6e939..f88c242 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): |