IronLanguages / IronLanguages/ironpython3
Duplicate file is closed when original file is closed
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
From https://github.com/IronLanguages/ironpython2/issues/92:
import os
with open("temp.txt", "wb+") as f:
f.write(b"test")
f.seek(os.SEEK_SET, 0)
x = os.dup(f.fileno())
g = os.fdopen(x, "rb")
assert g.read() == b"test"
fails with:
io.UnsupportedOperation: File not open for reading
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python snippet using os.dup, os.fdopen, and the original file's close behavior. Trace the implementation of these file-descriptor operations and add or run a regression test showing that g remains readable after f is closed; done means the assertion succeeds without io.UnsupportedOperation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100