[New-bugs-announce] [issue29159] Regression in bytes constructor

Alexander Belopolsky report at bugs.python.org
Wed Jan 4 14:49:54 EST 2017


New submission from Alexander Belopolsky:

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 <module>
    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)

----------
keywords: 3.6regression
messages: 284663
nosy: belopolsky, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Regression in bytes constructor
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29159>
_______________________________________


More information about the New-bugs-announce mailing list