Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use PyObject_HasAttrStringWithError for the six exercised stream finalization probes: writer flush/close and reader close, for compression and decompression. Missing optional methods remain allowed, while MemoryError and KeyboardInterrupt during lookup reach the caller.
Partially addresses #299: only these six stream flush/close probes. Constructor/copy_stream validation, fileno, and buffer-protocol errors are outside this patch.
Regression coverage: MemoryError and KeyboardInterrupt from lookup at all six sites; absent optional methods; close remains idempotent and retains existing closed-state semantics. Unchanged CFFI passes the same cases.
Validation on macOS 26.2 arm64 / CPython 3.12.14:
ZSTD_WARNINGS_AS_ERRORS=1 python setup.py build_ext --inplacebuilds the C and CFFI extensions.ZSTD_SLOW_TESTS=1 python -m pytest -q -n 4: 304 passed.PYTHON_ZSTANDARD_IMPORT_POLICY=cffi ZSTD_SLOW_TESTS=1 python -m pytest -q -n 4: 278 passed, 26 skipped.ruff check .,mypy tests/*.py zstandard/*.py, changed-fileruff format --check, andgit diff --checkpass.ruff format --check .reports only an existingsetup.pyindentation issue, reproduced on the untouched base.Both runs enabled
ZSTD_SLOW_TESTS=1with the default Hypothesis profile (100 examples), rather than the CI profile (1000 examples).An additional backend comparison found an existing difference: CFFI still looks up
closewhenclosefd=False, so lookup can raise there even though the C backend skips it. This patch preserves the C guard and leaves that separate CFFI behavior unchanged.Linux/Windows, other Python versions, PyPy, and the experimental Rust backend were not run locally.
AI disclosure: Code, tests, and this description were generated with OpenAI Codex and validated with automated local checks. This does not claim human review.