Skip to content

Preserve escaped newline text in formatted containers - #260

Open
FanWu-ai wants to merge 1 commit into
gruns:masterfrom
FanWu-ai:fix-nested-newline-escapes-20261009
Open

FanWu-ai wants to merge 1 commit into
gruns:masterfrom
FanWu-ai:fix-nested-newline-escapes-20261009

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 8, 2026

Copy link
Copy Markdown

Printing a configuration dictionary such as {'path': r'C:\new\report.csv'} currently inserts a newline into the displayed path. The generic argumentToString() replaces every backslash-n substring in pretty-printed output, including one that follows an already escaped backslash.

Consume escaped backslash pairs before converting a remaining newline escape. This preserves literal backslashes inside containers, bytes/bytearrays, and custom representations while retaining the existing rendering of real newlines and pretty-print wrapping. Top-level string dispatch is unchanged.

Five regression tests cover public ic() output, nested containers, odd/even backslash counts, bytes, custom repr, quotes and CRLF. All five fail against the original implementation (11 failing assertions/subtests).

Validation on Linux / CPython 3.12.14:

  • Original full unittest suite: 65 passed, no skips.
  • Final full unittest suite: 70 passed, no skips.
  • Project-pinned mypy 1.7.1: all five source files passed.
  • Source distribution and wheel builds passed.
  • 6,320 additional escape/newline boundary checks and git diff --check passed.

Related to the path-display reports in #130/#206. I checked #228: it changes the registered string formatter, whereas this fix concerns the generic formatter used for containers and other values. This does not claim to resolve the broader output-policy questions in #220.

AI assistance was used to prepare the implementation and regression tests. The hosted Python/OS matrix has not been run locally.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 8, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant