| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -859,6 +859,12 @@ class CBytesIOTest(PyBytesIOTest): | |||
| 859 | 859 | ioclass = io.BytesIO | |
| 860 | 860 | UnsupportedOperation = io.UnsupportedOperation | |
| 861 | 861 | ||
| 862 | + def test_readinto_overlapping_buffer(self): | ||
| 863 | + with self.ioclass(b'abcd') as stream: | ||
| 864 | + with stream.getbuffer()[1:] as target: | ||
| 865 | + self.assertEqual(stream.readinto(target), 3) | ||
| 866 | + self.assertEqual(stream.getvalue(), b'aabc') | ||
| 867 | + | ||
| 862 | 868 | def test_getstate(self): | |
| 863 | 869 | memio = self.ioclass() | |
| 864 | 870 | 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 | |
|---|---|---|---|
@@ -670,7 +670,7 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer) | |||
| 670 | 670 | ||
| 671 | 671 | assert(self->pos + len <= PY_SSIZE_T_MAX); | |
| 672 | 672 | assert(len >= 0); | |
| 673 | - memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len); | ||
| 673 | + memmove(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len); | ||
| 674 | 674 | self->pos += len; | |
| 675 | 675 | ||
| 676 | 676 | return PyLong_FromSsize_t(len); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments