gruns/icecream

Improve output for strings

Open

#220 建立於 2025年9月14日

在 GitHub 查看
 (0 留言) (1 反應) (1 負責人)Python (144 fork)batch import
enhancementhelp wanted

倉庫指標

Star
 (6,949 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Issue

Characters inside strings can modify their output by default. This leads to lost or misleading information when debugging.

Proposed Solution

Make IceCream output strings in a way that preserves all information by default. That means:

  • Showing control characters and invisibles explicitly instead of letting them affect terminal layout.
  • Deciding carefully whether newlines should render literally or as escaped symbols.

Examples

  1. Control characters alter the output instead of being visible. For instance, \b (backspace) removes characters → abc\bX prints as abX (information lost).
  2. Invisible Unicode characters disappear silently. For instance, Zero-width space (\u200B), left/right marks (\u200E, \u200F) are not shown → the user cannot tell they exist.
  3. Newlines are always shown as multi-line blocks. I’m not confident this should be the default behavior.
  4. Whitespace is ambiguous. For instance, tabs (\t) are expanded into spaces, making them indistinguishable.
  5. Long strings flood the output. Very long lines are printed in full without truncation or summary.
  6. Bytes / bytearray with control characters. For instance, bytes with \n or \x00 are printed raw, producing real line breaks or invisible content.

Open Questions

  1. Should escaped/visible mode be the default behavior?
  2. Should there be an option to output strings in a more readable form than one huge single line?
  3. Do we want to summarize long strings (length, line count, preview) instead of printing the full content by default?

貢獻者指南