Repository navigation
fix(foundation): close only an owned input on leaving the with block (#1999) - #2000
Conversation
|
GOOD TO GO at
No docs or example uses |
|
|
883c879 to
f56dc5c
Compare
|
Coverage: 91.54% (unit tier, Python 3.15,
Per-file detail: the |
…1999) Extractor.__exit__ closed the input unconditionally, so a with block closed a stream the caller supplied and still owned, against the ownership rule of #610 that _cleanup and the backstops follow. It now closes the input only when _owns_input() holds; the engine is still closed and the finaliser still detached. A caller's non-seekable stream stays open, as the SeekableReader wrapper is built with stream_closing off. - tests: a caller's seekable and non-seekable stream stay open after the block, and a path-opened handle is closed by __exit__ alone - test_extraction: the case pinning the old close now splits owned and caller-supplied input - changelog and close_extractor prose no longer say the block always closes the input
|
Rebased onto |
f56dc5c to
daa76d6
Compare
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Stacked on #1998. This PR carries #1998's commit, so merge #1998 first. After that, the diff is this PR's commit alone.
Option 1 from #1999. Leaving an
Extractor'swithblock now closes the input only if_owns_input()holds. That is the #610 rule, and_cleanupand the backstops already follow it. So:SeekableReader.This reverses the choice #636 made. The 1.5.0 changelog line and the
test_extraction.pycase that pinned the old close are updated to match.New
ContextExitFollowsOwnershiptests intest_extraction_ownership.pycover:__exit__alone.With the fix reverted, the seekable case fails (2 SUBFAILED), as does
test_extraction.py(1 failed).Closes #1999