-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Read the docs
✔️ : You might find a solution to your problem in the docs -- consider using the search function there.
Describe the bug
print_json produces invalid JSON when input includes values wider than console:
$ python repro.py | jq
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 3, column 3To Reproduce
repro.py:
import rich
data = {'long_str': "x" * 1000, 'long_int': int(2e128)}
rich.reconfigure(width=100)
rich.print_json(data=data)Platform
Reproduced in alacritty on macOS and Arch.
Diagnose
diagnose:
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=101 ColorSystem.TRUECOLOR> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│ height = 51 │
│ is_alt_screen = False │
│ is_dumb_terminal = False │
│ is_interactive = True │
│ is_jupyter = False │
│ is_terminal = True │
│ legacy_windows = False │
│ no_color = False │
│ options = ConsoleOptions( │
│ size=ConsoleDimensions(width=101, height=51), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=101, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=51, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=101, height=51) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 101 │
╰──────────────────────────────────────────────────────────────────────────────────╯
_windows:
platform="Linux"
WindowsConsoleFeatures(vt=False, truecolor=False)
$ pip freeze | grep rich
48:rich==10.13.0Did I help?
If I was able to resolve your problem, consider sponsoring my work on Rich, or buy me a coffee to say thanks.
Reactions are currently unavailable