| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -962,6 +962,12 @@ class CBytesIOTest(PyBytesIOTest): | |||
| 962 | 962 | ioclass = io.BytesIO | |
| 963 | 963 | UnsupportedOperation = io.UnsupportedOperation | |
| 964 | 964 | ||
| 965 | + def test_readinto_overlapping_buffer(self): | ||
| 966 | + with self.ioclass(b'abcd') as stream: | ||
| 967 | + with stream.getbuffer()[1:] as target: | ||
| 968 | + self.assertEqual(stream.readinto(target), 3) | ||
| 969 | + self.assertEqual(stream.getvalue(), b'aabc') | ||
| 970 | + | ||
| 965 | 971 | def test_getstate(self): | |
| 966 | 972 | memio = self.ioclass() | |
| 967 | 973 | state = memio.__getstate__() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fix :class:`io.BytesIO` reads into overlapping views of the same buffer. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -714,7 +714,7 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer) | |||
| 714 | 714 | ||
| 715 | 715 | assert(self->pos + len <= PY_SSIZE_T_MAX); | |
| 716 | 716 | assert(len >= 0); | |
| 717 | - memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len); | ||
| 717 | + memmove(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len); | ||
| 718 | 718 | self->pos += len; | |
| 719 | 719 | ||
| 720 | 720 | return PyLong_FromSsize_t(len); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments