Skip to content

Commit

Permalink
Support float castable values instead of just floats (bugfix) (#1658)
Browse files Browse the repository at this point in the history
* Support float castable values instead of just floats

This is done because the value may be 0, which
is a valid value for it (delay == 0)

* Now ints are supported, lets replace it with another invalid value
  • Loading branch information
Hook25 authored Dec 17, 2024
1 parent 65da1f9 commit f6f1b9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion checkbox-ng/plainbox/impl/session/resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,13 @@ def _rewrite_pathname(cls, pathname, location):
def _build_IOLogRecord(cls, record_repr):
"""Convert the representation of IOLogRecord back the object."""
_validate(record_repr, value_type=list)
delay = _validate(record_repr, key=0, value_type=float)
delay = _validate(record_repr, key=0)
try:
delay = float(delay)
except ValueError:
raise CorruptedSessionError(
"IOLogRecord has invalid delay {}".format(delay)
)
if delay < 0:
# TRANSLATORS: please keep delay untranslated
raise CorruptedSessionError(_("delay cannot be negative"))
Expand Down
4 changes: 3 additions & 1 deletion checkbox-ng/plainbox/impl/session/test_resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,9 @@ def test_build_IOLogRecord_bad_type_for_delay(self):
verify that _build_IOLogRecord() checks that ``delay`` is float
"""
with self.assertRaises(CorruptedSessionError):
self.parameters.resume_cls._build_IOLogRecord([0, "stdout", ""])
self.parameters.resume_cls._build_IOLogRecord(
["abc", "stdout", ""]
)

def test_build_IOLogRecord_negative_delay(self):
"""
Expand Down

0 comments on commit f6f1b9b

Please sign in to comment.