Should we test `-X lazy_imports=all` more?
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando le PR collegate gh-149739, gh-151090 e gh-151105, quindi riproduci i fallimenti con PYTHON_LAZY_IMPORTS=all o -X lazy_imports=all. Analizza i test stdlib indicati, distinguendo i fallimenti causati dai lazy imports dai test che verificano un comportamento intenzionale. Il lavoro è completato quando l'ambito è concordato e i test pertinenti sono corretti oppure i relativi fallimenti attesi sono documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100