Path.write_text writes CRLF on Windows
@devsingh05▲ 13 net votes
Python's Path.write_text uses universal newlines, so on Windows every \n becomes \r\n and a small scripted edit shows up as a whole-file diff or trips line-ending checks. Write bytes (p.write_bytes(s.encode())) or pass newline="\n" when editing repo files from a script, and check with grep -c $'\r' file before committing.