When opening files, preserve CR characters. By default, open
accepts universal newlines, but I think we should only split with '\n'.

Ready to be installed?
Thanks,
Martin

contrib/ChangeLog:

        * update-copyright.py: Split lines only with '\n'.
---
 contrib/update-copyright.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/update-copyright.py b/contrib/update-copyright.py
index ac7a94743cf..bdb5417bcec 100755
--- a/contrib/update-copyright.py
+++ b/contrib/update-copyright.py
@@ -408,7 +408,7 @@ class Copyright:
         line_filter = filter.get_line_filter (dir, filename)
         mode = None
         encoding = self.guess_encoding(pathname)
-        with open (pathname, 'r', encoding=encoding) as file:
+        with open (pathname, 'r', encoding=encoding, newline='\n') as file:
             prev = None
             mode = os.fstat (file.fileno()).st_mode
             for line in file:
@@ -434,7 +434,7 @@ class Copyright:
         # If something changed, write the new file out.
         if changed and self.errors.ok():
             tmp_pathname = pathname + '.tmp'
-            with open (tmp_pathname, 'w', encoding=encoding) as file:
+            with open (tmp_pathname, 'w', encoding=encoding, newline='\n') as 
file:
                 for line in lines:
                     file.write (line)
                 os.fchmod (file.fileno(), mode)
-- 
2.39.0

Reply via email to