Issue 34826: io.BufferedReader crashes in 2.7 on memoryview attribute access (original) (raw)

The following test code segfaults on Python 2.7:

import io
class X(io.RawIOBase):
  def readable(self):
    return True
  def readinto(self, b):
    if isinstance(b, memoryview):
      print(b.format)  # XXX boom, crashes here.
    return 0

io.BufferedReader(X()).read(8)

The crash happens on the b.format attribute access.

This does not happen on 3.6.