ZoneInfo object raises OSError instead of ZoneInfoNotFoundError for timezone input larger than 255 characters
未关闭
还没有人认领这个 Issue。
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 558
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Lib/zoneinfo/_common.py 中引用的 open 调用开始,使用 ZoneInfo("a"*256) 重现该问题。检查针对无效时区输入的现有异常行为,然后验证长输入产生的是文档所述的异常,而不是 OSError。关联的 PR gh-99602 表明相关工作已经在进行中。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 20/100