mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.14] gh-142594: fix by property calls io.TextIOWrapper.detach (GH-142706) (GH-142755)
(cherry picked from commit 1d3854a19a)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
This commit is contained in:
parent
b9cbdde80d
commit
58da2a9d94
3 changed files with 21 additions and 0 deletions
|
|
@ -4194,6 +4194,22 @@ def write(self, data):
|
|||
self.assertEqual([b"abcdef", b"middle", b"g"*chunk_size],
|
||||
buf._write_stack)
|
||||
|
||||
def test_issue142594(self):
|
||||
wrapper = None
|
||||
detached = False
|
||||
class ReentrantRawIO(self.RawIOBase):
|
||||
@property
|
||||
def closed(self):
|
||||
nonlocal detached
|
||||
if wrapper is not None and not detached:
|
||||
detached = True
|
||||
wrapper.detach()
|
||||
return False
|
||||
|
||||
raw = ReentrantRawIO()
|
||||
wrapper = self.TextIOWrapper(raw)
|
||||
wrapper.close() # should not crash
|
||||
|
||||
|
||||
class PyTextIOWrapperTest(TextIOWrapperTest):
|
||||
io = pyio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue