Skip to content

Commit 9fe1625

Browse files
Include error handling when trying to set UTF-8 outputs
1 parent a01975e commit 9fe1625

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/usethis/_console.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
from rich.table import Table
1313

1414
# Unicode support - but we need to be able to write bytes
15-
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.buffer)
16-
sys.stderr = codecs.getwriter("utf-8")(sys.stderr.buffer)
15+
try:
16+
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.buffer)
17+
sys.stderr = codecs.getwriter("utf-8")(sys.stderr.buffer)
18+
except AttributeError:
19+
# e.g. in Jupyter
20+
pass
1721

1822
console = Console()
1923
err_console = Console(stderr=True)

0 commit comments

Comments
 (0)