mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] gh-80109: Fix io.TextIOWrapper dropping the internal buffer during write() (GH-22535) (GH-113808)
io.TextIOWrapper was dropping the internal decoding buffer
during read() and write() calls.
(cherry picked from commit 73c9326563
)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
parent
db6f297d44
commit
ad2d5ec97e
4 changed files with 24 additions and 8 deletions
|
@ -3891,6 +3891,14 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
t.write('x')
|
||||
t.tell()
|
||||
|
||||
def test_issue35928(self):
|
||||
p = self.BufferedRWPair(self.BytesIO(b'foo\nbar\n'), self.BytesIO())
|
||||
f = self.TextIOWrapper(p)
|
||||
res = f.readline()
|
||||
self.assertEqual(res, 'foo\n')
|
||||
f.write(res)
|
||||
self.assertEqual(res + f.readline(), 'foo\nbar\n')
|
||||
|
||||
|
||||
class MemviewBytesIO(io.BytesIO):
|
||||
'''A BytesIO object whose read method returns memoryviews
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue