python / python/cpython

Split Up _testsinglephase.c and _testmultiphase.c

Aperta
#124,983 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

extension-modules tests type-refactor
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

(low priority)

Modules/_testsinglephase.c and Modules/_testmultiphase.c both contain the implementations of multiple modules. We should consider splitting up both files, so each contained module has its own file.

Here are several reasons why this may be worth doing:

  • testing with a module hidden in another's .so file is awkward and makes those tests harder to understand
  • it's easier to accidentally leak C-module global data between modules when they are implemented in the same file
  • when adding a new module, it's trickier (less familiar) to implement it in an existing file than in a new file [^1]

[^1]: However, adding it to an existing file is also simpler in how adding a new file involves tweaking the build. See the devguide.

Furthermore, both files were added to test specific import functionality. As far as I can tell[^2], that never included any need for the multiple-modules-in-one-file approach. However, currently they are the only place where we're testing the feature, regardless of how unintentionally or superficially. gh-124978 targets fixing that lack of explicit testing, including moving away from _testsinglephase.c and _testmultiphase.c (e.g. using the dedicated Modules/_testimportmultiple.c).

[^2]: I personally added Modules/_testsinglephase.c and @encukou added _testmultiphase.c.

All that said, splitting up the files is a fairly low priority task. The status quo isn't ideal but it isn't that bad either.


Here's how I see us taking care of this:

  1. make sure multiple-modules-in-one-file is tested via the dedicated Modules/_testimportmultiple.c [^2] (see gh-124978)
  2. create the Modules/_testsinglephase directory
  3. move each module from _testsinglephase.c to its own file (see the devguide)
  4. update the relevant tests
  5. delete Modules/_testsinglephase.c
  6. repeat steps 2-5 for Modules/_testmultiphase.c

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando Modules/_testsinglephase.c e Modules/_testmultiphase.c, i test pertinenti e gh-124978, quindi segui il workflow extension-module del devguide. Il lavoro è completato quando il comportamento di più moduli è coperto esplicitamente, ogni modulo contenuto ha il proprio file, i test pertinenti sono aggiornati ed entrambi i file originali sono rimossi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c
Ambito
build-system, testing
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.