Skip to content

Detect compressed tar archives during extraction - #193

Open
Gonghan-Princess wants to merge 2 commits into
fabiocaccamo:mainfrom
Gonghan-Princess:codex/fix-compressed-tar-extraction
Open

Gonghan-Princess wants to merge 2 commits into
fabiocaccamo:mainfrom
Gonghan-Princess:codex/fix-compressed-tar-extraction

Conversation

@Gonghan-Princess

@Gonghan-Princess Gonghan-Princess commented Sep 11, 2026

Copy link
Copy Markdown

Describe your changes

create_tar_file(..., compression="gz"/"bz2"/"xz") produces archives that extract_tar_file() currently rejects with tarfile.ReadError. Open archives through tarfile.open(..., "r:*") so extraction detects compression from the archive content.

Parameterize the existing extraction and autodelete tests over plain tar, gzip, bzip2, and xz, and cover extracting selected members for each format. The tests deliberately use a .tar filename for every format so detection is independent of the extension.

Validation on Windows / Python 3.12.10:

  • Before the fix: 9 compressed-archive cases failed; 7 controls passed.
  • Archive tests after the fix: 16 passed.
  • Full suite: 175 passed, 3 platform-dependent permission tests skipped; coverage 98.36% (90% required).
  • Strict mypy 2.3.1: passed for 13 source files.
  • Wheel and sdist builds passed; verified the built wheel contains the corrected reader.
  • Configured all-file pre-commit hooks passed, including pinned mypy 2.1.0. Ruff wrapped one overlong test call; all 16 archive tests passed again after formatting.

The other CI operating systems and Python 3.10/3.11/3.13/3.14 were not run locally. Existing extraction-filter handling and delete-after-success behavior are unchanged.

Related issue

No existing issue identified; this was reproduced by round-tripping archives through the public creation and extraction functions.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

AI disclosure: OpenAI Codex prepared the fix and tests and performed an independent agent review and verification. The self-review checkbox refers to that AI review; no human review is claimed. No third-party source code was copied.

CI follow-up

Codacy reported B101 on the two new pytest assertions in the selected-member regression test. Add narrowly scoped # nosec B101 annotations with a test-only explanation. The assertions and Python AST are unchanged. Bandit 1.9.4 confirms exactly those two findings disappear; all 34 pre-existing findings in that test file remain. The 16 archive tests and all configured pre-commit hooks (including Ruff and mypy) pass after the annotations.

Scrutinizer reports the same analysis/setup error on the unchanged base commit, before this PR: base inspection. Its underlying log could not be accessed, so the exact service error is still unverified. The repository's full local suite passes (175 passed, 3 platform skips, 98.36% coverage); the new commit now passes all 15 GitHub Actions OS/Python matrix jobs, Codacy, and both Codecov checks (18 successful checks total). Scrutinizer still reports its pre-existing analysis/setup error.

@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.48%. Comparing base (68a343a) to head (e246529).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #193   +/-   ##
=======================================
  Coverage   98.48%   98.48%           
=======================================
  Files          13       13           
  Lines         793      793           
=======================================
  Hits          781      781           
  Misses         12       12           
Flag Coverage Δ
unittests 98.48% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant