python / python/cpython

Split Up _testsinglephase.c and _testmultiphase.c

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

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

extension-modules tests type-refactor
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

(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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず Modules/_testsinglephase.c と Modules/_testmultiphase.c、関連するテスト、gh-124978 を確認し、その後 devguide の extension-module ワークフローに従ってください。完了の条件は、複数モジュールの動作が明示的にカバーされ、含まれる各モジュールに独自のファイルがあり、関連するテストが更新され、元の 2 つのファイルが削除されていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c
領域
build-system, testing
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。