%%bash --out only stores last line of output in output variable
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
core/magics/script.py の217行目付近から始め、複数行の出力を含め、例にある %%bash --out の動作を再現します。各 stdout 行が出力変数にどのように割り当てられるかを追跡し、その後、--out が最後の行だけでなく完全な出力を保持するように、リグレッションテストのカバレッジを追加または更新します。
索引モデルが issue の本文から書いたものです。
説明
%%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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ipython/ipython のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
ipython/ipython の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
canonical/paas-charm#368 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
StevenBlack/hosts#3256 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
qualcomm/qai-appbuilder#275 ·