email.utils.collapse_rfc2231_value raises AttributeError on non-3-tuples
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
Issue
collapse_rfc2231_value raises AttributeError: 'tuple' object has no attribute 'startswith' when passed a tuple whose length is not 3. The guard if not isinstance(value, tuple) or len(value) != 3 is meant to handle this case, but falls through to unquote(value) which expects a string.
Reproducer
from email.utils import collapse_rfc2231_value
collapse_rfc2231_value(('a', 'b'))
# AttributeError: 'tuple' object has no attribute 'startswith'
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-145825
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
Start with email.utils.collapse_rfc2231_value and run the reproducer from the issue using a two-element tuple. Determine the intended handling for tuples whose length is not three, then add or update regression coverage so the reported AttributeError no longer occurs. Linked PR gh-145825 indicates that work is already underway.
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
- Mostly clear
- Newbie friendliness
- 25/100