tarfile.TarFile.next() adds an unnecessary traceback frame when reraising exceptions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
description:
https://gist.github.com/devdanzin/f8af359770ff200eac8474de5644be82
tarfile.TarFile.next() currently reraises non-zlib exceptions with raise e
inside its generic exception handler:
except Exception as e:
try:
import zlib
if isinstance(e, zlib.error):
raise ReadError(f'zlib error: {e}') from None
else:
raise e
except ImportError:
raise e
Using raise e adds an extra traceback frame at the re-raise site. A bare
raise would keep the traceback cleaner while preserving the original exception
and its traceback.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-149761
- gh-157257
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
Search the tarfile module for TarFile.next() and inspect the generic exception handler shown in the issue. Confirm the traceback difference described in the linked gist, then run the tarfile tests after the exception-handling change to verify that non-zlib exceptions retain their original traceback and zlib errors remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100