ZoneInfo object raises OSError instead of ZoneInfoNotFoundError for timezone input larger than 255 characters
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Bug report
According to documentation all calls to ZoneInfo should raise ValueError or ZoneInfoNotFoundError.
Creating a ZoneInfo object with an invalid very long timezone (length > 255) an OSError is raised instead (OSError: [Errno 36] File name too long).
I believe that https://github.com/python/cpython/blob/29f1b0bb1ff73dcc28f0ca7e11794141b6de58c9/Lib/zoneinfo/_common.py#L11-L24 should also handle the OSError exception raised by open and reraise it to ZoneInfoNotFoundError.
Sample code for reproduction:
from zoneinfo import ZoneInfo
ZoneInfo("a"*256)
Your environment
- CPython versions tested on: Python 3.10.4
- Operating system and architecture: Debian GNU/Linux 11 (bullseye)
Linked PRs
- gh-99602
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 in Lib/zoneinfo/_common.py at the referenced open call and reproduce the issue with ZoneInfo("a"*256). Check the existing exception behavior for invalid timezone inputs, then verify that the long input produces the documented exception rather than OSError. Linked PR gh-99602 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
- Clearly specified
- Newbie friendliness
- 20/100