Issue 29159: Regression in bytes constructor - Python tracker
Author: Alexander Belopolsky (belopolsky) *
Description : Consider the following code:
$ cat bug.py
from array import array
class C(array):
def new(cls):
return array.new(cls, 'B', b'abc')
def index(self):
raise TypeError
x = C()
print(bytes(x))
It works under python 3.5:
$ python3.5 bug.py
b'abc'
but raises a TypeError under python 3.6:
$ python3.6 bug.py
Traceback (most recent call last):
File "bug.py", line 8, in
print(bytes(x))
File "bug.py", line 6, in __index__
raise TypeError
TypeError
It looks like this was introduced in issue #27704.
(Ref: e/pyq#827)