mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
try to call __bytes__ before __index__ (closes #16722)
This commit is contained in:
parent
1f415cf2c2
commit
5ff3f73d94
3 changed files with 37 additions and 5 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue