jtamate added a comment.
Another solution (not tested here but used in other projects) could be to use with open(source, "r", encoding="utf-8") as f: (or if the file could contain the aberration BOM, you could use "utf-8-sig") And it should convert automatically all kind of line-ends and still return text. I'm assuming this is for python 3.5 or later. REPOSITORY R240 Extra CMake Modules REVISION DETAIL https://phabricator.kde.org/D15068 To: bruns, #frameworks Cc: jtamate, kde-frameworks-devel, kde-buildsystem, michaelh, ngraham, bruns