Although #21 was fixed in #35 (by these 5 lines in 4dc8b2b), the current error does not list the line number, nor indicate that it's about the last line of the file:
[
{
'code': 'no_line_separators',
'message': 'Every line must end with either a carriage return and line feed characters or just a line feed character',
'line': None
}
]
Either:
the line number must be specified; and/or
the text message should be made explicit it's about the last line.
Add explicit_line_no=None to the _add_error definition, plus self._line_no if explicit_line_no = None else explicit_line_no and a self.lines[-1]._line_no to the _add_error call in the 'empty content after \r?\n' check in validate_contents.
Change the text to 'Every line, including the last one, must end with either a carriage return and line feed characters or just a line feed character'
Although #21 was fixed in #35 (by these 5 lines in
4dc8b2b
), the current error does not list the line number, nor indicate that it's about the last line of the file:Either:
So the problem in the code is here: https://github.com/DigitalTrustCenter/sectxt/blob/79bb38634f2d3c5bed28cce4b47edb98bcd44948/sectxt/__init__.py#L92-L93 It set's the
_line_no
toNone
, and then invalidate_contents
the check is done: https://github.com/DigitalTrustCenter/sectxt/blob/79bb38634f2d3c5bed28cce4b47edb98bcd44948/sectxt/__init__.py#L284-L290 In the_add_error
the_line_no
is used: https://github.com/DigitalTrustCenter/sectxt/blob/79bb38634f2d3c5bed28cce4b47edb98bcd44948/sectxt/__init__.py#L95-L101I would propose doing both:
explicit_line_no=None
to the_add_error
definition, plusself._line_no if explicit_line_no = None else explicit_line_no
and aself.lines[-1]._line_no
to the_add_error
call in the 'empty content after\r?\n
' check invalidate_contents
.