RoundTripScanner incorrectly scans comments with CRLF line endings
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
When loading a file using RoundTripParser on Windows, RoundTripScanner.scan_next_token() will mistakenly scan the first CRLF of each comment as "\r\n" instead of "\n". On dumping the parsed data to a file Python will replace the "\n" with a full CRLF, resulting in an additional CR character per comment.
To reproduce the bug:
By passing an text stream (mode="r") to yaml.load, every "\r\n" gets translated to "\n", which ruamel will parse correctly. When passing a Path object instead ruamel will open a binary stream (mode="rb"), encounter the bug described above and write the file using a text stream which translates "\n" to "\r\n" resulting in an additional "\r" in the first line of every comment.
example.yaml contained a typo. Here is the corrected version