Skip to content

Close patch input files when parsing raises - #77

Open
awais-ur-rehman wants to merge 1 commit into
techtonik:masterfrom
awais-ur-rehman:feat/close-patch-input-on-errors
Open

awais-ur-rehman wants to merge 1 commit into
techtonik:masterfrom
awais-ur-rehman:feat/close-patch-input-on-errors

Conversation

@awais-ur-rehman

Copy link
Copy Markdown

Summary

fromfile closes its input only after parse returns. Use a context manager so the file also closes when parsing raises, while preserving the exception and the existing valid/invalid-file return values.

Fixes #58.

Breaking Changes

None.

Testing

  • python -m coverage run tests/run_tests.py: all 47 tests pass on Python 3.11.15 and 3.14.3. The new real-file exception case fails on the base; valid/invalid controls pass.
  • Configured pypack ZIP build and ZIP --help smoke test pass. The existing generated-unittest return-value warnings remain.
  • To reproduce, make PatchSet.parse raise after receiving an opened file. The same exception must propagate and the captured file must be closed.

Prepared with OpenAI Codex assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fromfile leaks file pointer in case parse raises exception

1 participant

⌂ Proxy