Skip to content

Checksum files written on Windows have doubled carriage returns (\r\r\n instead of \r\n) #93

Description

@ras07

On Windows, every text-format checksum file cfv writes terminates each line with \r\r\n (two carriage returns followed by a line feed) instead of the intended \r\n. Here's the Format-Hex output of a test .sfv file created on Windows:

PS C:\tmp\test> Format-Hex .\test.sfv


           Path: C:\tmp\test\test.sfv

           00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000   3B 20 47 65 6E 65 72 61 74 65 64 20 62 79 20 63  ; Generated by c
00000010   66 76 20 76 33 2E 32 2E 30 20 6F 6E 20 32 30 32  fv v3.2.0 on 202
00000020   36 2D 30 37 2D 30 38 20 61 74 20 32 30 3A 32 38  6-07-08 at 20:28
00000030   2E 34 32 0D 0D 0A 3B 0D 0D 0A 66 69 6C 65 31 20  .42...;...file1
00000040   30 30 30 30 30 30 30 30 0D 0D 0A 66 69 6C 65 32  00000000...file2
00000050   20 30 30 30 30 30 30 30 30 0D 0D 0A              00000000...

The 0D 0D 0A at the end of each line is the \r\r\n.

This is an artifact of TextIOWrapper in Python3 being kind of dumb. On Windows, TextIOWrapper tries to "fix" a \n by adding a \r in front of it. But the handlers for each file format in cfv already did that, so it ends up with two \r's in a row.

Simply specifying newline='' in the TextIOWrapper call will solve this for Windows (and will have no effect on Linux, since the line terminator will already be the correct one on that platform). I'll submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions