◐ Shell
clean mode source ↗

Message 138463 - Python tracker

As for the "<memory at %p>" string, when _io.BufferedWriter prepares the byte buffer into a PyMemoryView wrapper and passes it into the raw IO object:

    res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_write, memobj, NULL);

For some reason, memobj.__repr__ is called before being passed to the raw IO's write method.

I can't reproduce this odd behavior using a dumb raw IO that extends _io.RawIOBase. Mimicking what pyserial does, however, reproduces both issues (see attached).