python / python/cpython

non-blocking reads of binary and text streams handle no-data differently

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

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

stdlib topic-subprocess type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:
proc = subprocess.Popen(
    ['bash', '-c', 'sleep 10; echo hello'],
    stdout=subprocess.PIPE,
    text=True
)
os.set_blocking(proc.stdout.fileno(), False)
print(repr(proc.stdout.read(8192)))

Refer to issue #57531 for discussion on what should happen in general, but I'm filing this to point out that when text=True the output is an empty string (indistinguishable from EOF, which is a problem), and when text=False the result is None (while an empty string is produced only on EOF).

They should probably behave consistently, and also EOF should be distinguishable from no-data-yet; making the binary behaviour preferable.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

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

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

はじめの一歩

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

調査の方向性

この issue の subprocess.Popen の例から始め、CPython 3.13/Linux で text=True と text=False のノンブロッキング読み取り結果を比較してください。提案されている一般的な動作については issue #57531 を読んでください。no-data-yet と EOF を区別でき、バイナリストリームとテキストストリームが一貫して動作すれば完了です。

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

評価

技術スタック
python
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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