python / python/cpython

Add reproducibility test for `gzip.compress()`

未关闭
#131,697 3 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

tests type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

The issue https://github.com/python/cpython/issues/112346 was reported, which was a failure to keep reproducibility in gzip module output from Python 3.10 to 3.11.

There was a fix discussed and rejected in https://github.com/python/cpython/issues/112346

I think it makes sense not to actually change things back, but failing to merge the PR means we also failed to add unit tests.

Can we please add a general-purpose, fragile reproducibility test for the gzip module, so that this problem does not recur?

Ex. test that the output of gzip.compress("Hello world") remains stable

def test_gzip_reproducibility():
    """If this test fails, gzip.compress does not give reproducible output. Either fix that, or document the change in What's New and change the constant 'expected' below."""
    expected = b'\x1f\x8b\x08\x00\xa2\xd2\xe1g\x02\xff\xf3H\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00R\x9e\xd6\x8b\x0b\x00\x00\x00'
    assert gzip.compress(b"Hello world") == expected

    expected = 
b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xf3H\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00R\x9e\xd6\x8b\x0b\x00\x00\x00'
    assert gzip.compress(b"Hello world", mtime=0) == expected    
Linked PRs
  • gh-151214

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

开始之前,检查链接的 PR gh-151214,并找到现有的 gzip 模块测试。添加 issue 中所示的 gzip.compress() 可复现性检查,然后确认预期输出仍然稳定,并说明 What's New 中任何有意的更改。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
testing-qa
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。