Skip to content

Commit 5cec3e1

Browse files
committed
Make traceback a getter
1 parent fefabf8 commit 5cec3e1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

js/src/messaging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class ExecutionError {
2525
/**
2626
* Returns the traceback of the error as a string.
2727
*/
28-
traceback(): string {
28+
get traceback(): string {
2929
return this.tracebackRaw.join('\n')
3030
}
3131
}

python/tests/test_streaming.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
def test_streaming_output():
55
out = []
66
with CodeInterpreter() as sandbox:
7+
78
def test(line) -> int:
89
out.append(line)
910
return 1
11+
1012
sandbox.notebook.exec_cell("print(1)", on_stdout=test)
1113

1214
assert len(out) == 1
@@ -16,7 +18,9 @@ def test(line) -> int:
1618
def test_streaming_error():
1719
out = []
1820
with CodeInterpreter() as sandbox:
19-
sandbox.notebook.exec_cell("import sys;print(1, file=sys.stderr)", on_stderr=out.append)
21+
sandbox.notebook.exec_cell(
22+
"import sys;print(1, file=sys.stderr)", on_stderr=out.append
23+
)
2024

2125
assert len(out) == 1
2226
assert out[0].line == "1\n"
@@ -41,4 +45,3 @@ def test_streaming_result():
4145
sandbox.notebook.exec_cell(code, on_result=out.append)
4246

4347
assert len(out) == 2
44-

0 commit comments

Comments
 (0)