Skip to content

Commit 39a5b7e

Browse files
merge out_stream and err_stream
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
1 parent c6db3c5 commit 39a5b7e

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

IPython/core/magics/basic.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def notebook(self, s):
572572
cell = v4.new_code_cell(execution_count=execution_count, source=source)
573573

574574
for output in outputs[execution_count]:
575-
if output.output_type == "out_stream":
575+
if output.output_type in {"out_stream", "err_stream"}:
576576
text_data = []
577577
for mime_type, data in output.bundle.items():
578578
if isinstance(data, list):
@@ -589,27 +589,10 @@ def notebook(self, s):
589589
normalized_text.append(line + "\n")
590590
elif line: # Last line only if it's not empty
591591
normalized_text.append(line + "\n")
592-
cell.outputs.append(v4.new_output("stream", text=normalized_text))
593-
594-
elif output.output_type == "err_stream":
595-
text_data = []
596-
for mime_type, data in output.bundle.items():
597-
if isinstance(data, list):
598-
text_data.extend(data)
599-
else:
600-
text_data.append(data)
601-
full_text = "".join(text_data)
602-
full_text = full_text.replace("\\n", "\n")
603-
normalized_text = []
604-
lines = full_text.split("\n")
605-
for i, line in enumerate(lines):
606-
if i < len(lines) - 1:
607-
normalized_text.append(line + "\n")
608-
elif line:
609-
normalized_text.append(line + "\n")
610-
err_output = v4.new_output("stream", text=normalized_text)
611-
err_output.name = "stderr"
612-
cell.outputs.append(err_output)
592+
stream_output = v4.new_output("stream", text=normalized_text)
593+
if output.output_type == "err_stream":
594+
err_output.name = "stderr"
595+
cell.outputs.append(stream_output)
613596

614597
elif output.output_type == "execute_result":
615598
data_dict = {}

0 commit comments

Comments
 (0)