Skip to content

Commit

Permalink
Test annotation parsing: strip line endings
Browse files Browse the repository at this point in the history
Since annotation parsing opens the file in byte mode, carriage returns are not
stripped away, and can ultimately be included as part of an annotation's data.

A consequence of this is that `DMLC-FLAG` will pass stray carriage returns to
DMLC on Windows. mini-python will apparently discard these, but Pypy *doesn't*,
and that can cause parsing of the flag to fail.

The fix to this is to strip away any line endings explicitly.
  • Loading branch information
lwaern-intel committed Jan 22, 2025
1 parent 20a93d6 commit fd41f66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def test_flags(self, filename=None, append_to=None):
else:
flags = append_to
for (linenum, line) in enumerate(open(filename, "rb"), 2):
m = annotation_re.match(line)
m = annotation_re.match(line.rstrip(b'\r\n'))
if not m:
continue
(key, data) = m.groups()
Expand Down

0 comments on commit fd41f66

Please sign in to comment.