Should we test `-X lazy_imports=all` more?
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Inspired by #149321 I decided to see how well the test suite works with PYTHON_LAZY_IMPORTS=all / -X lazy_imports=all, which makes all imports lazy. It's nowhere near as bad as the none option that we're considering removing, but a few parts of the stdlib are broken, and it seems worth considering if we want to fix these.
Concrete issues I noticed:
- #144957 breaks test_typing
test_unittestfails becauseunittest.mainbecomes a module instead of a function.test_structis broken because of a test that doesexec("import struct")in a function; lazy imports are disallowed within functions. Similar issues affecttest_enum,test_traceback, andtest_future.test_symtableis broken because it fills its_flagslist by iterating overglobals(), which means it starts containing lazy import marker objects. Similarlytest_inspectbreaks because it iterates overvars()of a module.
A few tests fail for legitimate reasons; test_compileall tests that an import triggers pyc compilation; test_builtin asserts that __import__ is used when in fact __lazy_import__ gets used.
Full list of failed modules on my machine:
test.test_future_stmt.test_future
test.test_inspect.test_inspect
test.test_pydoc.test_pydoc
test___all__
test__interpreters
test_builtin
test_capi
test_clinic
test_compileall
test_crossinterp
test_datetime
test_enum
test_generated_cases
test_idle
test_import
test_importlib
test_interpreters
test_json
test_lazy_import
test_struct
test_subprocess
test_symtable
test_tools
test_trace
test_traceback
test_tracemalloc
test_typing
test_unittest
test_xmlrpc
test_zipfile
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-149739
- gh-151090
- gh-151105
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされている PR gh-149739、gh-151090、gh-151105 を確認し、その後 PYTHON_LAZY_IMPORTS=all または -X lazy_imports=all で失敗を再現します。指定された stdlib テストを調査し、lazy imports が原因の失敗と、意図された動作を検証しているテストを切り分けます。スコープについて合意し、関連するテストを修正するか、想定される失敗を文書化できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- testing-qa
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100