contrib: ignore CR in update-copyright.py
Checks
Commit Message
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(-)
Comments
On 1/17/23 05:00, Martin Liška wrote:
> 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'.
OK.
jeff
@@ -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)