This issue might serve as partial documentation.
This took a lot of digging to find. A carriage return sent over usb serial is replaced with a new line character when sent e.g. sys.stdout.write('String\n'), print('String\n', end='') or print('String') becomes 'String\r\n' on the pc side.
The source of the change seems to be the mp_hal_stdout_tx_strn_cooked() function in \lib\utils\stdout_helpers.c
It has the comment:
"Send "cooked" string of given length, where every occurrence of LF character is replaced with CR LF."