python / python/cpython

Add reproducibility test for `gzip.compress()`

オープン
#131,697 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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. リポジトリをフォークし、ブランチを切って変更します。
  4. 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 を短くまとめたダイジェスト。