Skip to content

escape or reject a bare carriage return in multiline strings#539

Open
netliomax25-code wants to merge 1 commit into
python-poetry:masterfrom
netliomax25-code:multiline-bare-cr
Open

escape or reject a bare carriage return in multiline strings#539
netliomax25-code wants to merge 1 commit into
python-poetry:masterfrom
netliomax25-code:multiline-bare-cr

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor

Summary

  1. String.from_raw builds a multiline basic string by escaping every control character except a line feed and a carriage return, so a lone CR (one that is not the CR of a CRLF pair) is written out raw.
  2. The multiline literal path drops that same CR from invalid_sequences, so a lone CR there is neither escaped nor rejected.
  3. Either way tomlkit.string(value, multiline=True) and its literal variant emit a document with a raw lone CR, which the tomlkit parser and the stdlib tomllib both reject as a control character, so the value stops round-tripping.
  4. Escape a lone CR as \r for multiline basic strings, and raise InvalidStringError for multiline literal strings; LF and CRLF line endings are left untouched.

Agent Drafting Metadata

  • Agent:
  • Model:
  • Notes:

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