Should we test `-X lazy_imports=all` more?
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc xem xét các PR được liên kết gh-149739, gh-151090 và gh-151105, sau đó tái hiện các lỗi bằng PYTHON_LAZY_IMPORTS=all hoặc -X lazy_imports=all. Điều tra các bài kiểm thử stdlib được nêu, phân biệt các lỗi do lazy imports gây ra với các bài kiểm thử xác nhận hành vi có chủ đích. Công việc được xem là hoàn tất khi phạm vi đã được thống nhất và các bài kiểm thử liên quan đã được sửa hoặc các lỗi dự kiến của chúng đã được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- testing-qa
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100