Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

%%bash --out only stores last line of output in output variable

オープン 初心者向け
#13,499 コメント 9 件 リアクション 1 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
bash, python
領域
cli, tooling

調査の方向性

core/magics/script.py の217行目付近から始め、複数行の出力を含め、例にある %%bash --out の動作を再現します。各 stdout 行が出力変数にどのように割り当てられるかを追跡し、その後、--out が最後の行だけでなく完全な出力を保持するように、リグレッションテストのカバレッジを追加または更新します。

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

説明

bug magics

%%bash cell magic writes output as expected to the IPython terminal and JupyterLab, but when --out is used, it's as if it overwrites the value in the output variable with each new line of stdout, even when echoing a multi-line string.

I think this may be due to line 217 in core/magics/script.py:

                    self.shell.user_ns[stream_arg] = line

Which may have originated from Line-buffered output for %%magic scripts ? I'm not following whether this is intended behavior, and I should use the --bg flag and handle the _AsyncIOProxy object created, or if this output string should be initialized and then appended to with each step (KeyError raised the first time if that line is changed from = to +=).

Seeing this on Windows and OSX for IPython 8.

Python 3.9.5 (default, May 18 2021, 12:31:01) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %%bash
   ...: echo hello
   ...: echo world
hello
world

In [2]: %%bash --out tmp
   ...: echo hello
   ...: echo world

In [3]: tmp
Out[3]: 'world\n'

In [4]: %%bash --out tmp2
   ...: echo "alpha
   ...: beta"

In [5]: tmp2
Out[5]: 'beta\n'
主要言語
Python
スター
16.8k
フォーク
4.5k
平均マージ
1日 2時間
マージ済み PR(30日)
6

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

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

はじめの一歩

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

ipython/ipython のほかの issue

ipython/ipython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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