diff options
author | Mathieu Le Marec - Pasquet <kiorky@cryptelium.net> | 2019-01-27 17:07:01 +0100 |
---|---|---|
committer | Mathieu Le Marec - Pasquet <kiorky@cryptelium.net> | 2019-03-26 14:36:18 +0100 |
commit | 7693536a913172c97ba983c0449685f394cb7d4d (patch) | |
tree | 9197e15685436d2fd5b02b6c9a9468521f66267f | |
parent | 4ea102eabd9d718bb5d59f9b5360ab15f5971233 (diff) | |
download | croniter-7693536a913172c97ba983c0449685f394cb7d4d.tar.gz |
Handle invalid ranges correctly
This fixes #114
-rw-r--r-- | src/croniter/croniter.py | 6 | ||||
-rwxr-xr-x | src/croniter/tests/test_croniter.py | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/croniter/croniter.py b/src/croniter/croniter.py index 3398227..f21e368 100644 --- a/src/croniter/croniter.py +++ b/src/croniter/croniter.py @@ -511,7 +511,11 @@ class croniter(object): "[{0}] is not acceptable".format(expr_format)) low, high, step = map(int, [low, high, step]) - rng = range(low, high + 1, step) + try: + rng = range(low, high + 1, step) + except ValueError as exc: + raise CroniterBadCronError( + 'invalid range: {0}'.format(exc)) e_list += (["{0}#{1}".format(item, nth) for item in rng] if i == 4 and nth else rng) else: diff --git a/src/croniter/tests/test_croniter.py b/src/croniter/tests/test_croniter.py index 2d23525..8b30fef 100755 --- a/src/croniter/tests/test_croniter.py +++ b/src/croniter/tests/test_croniter.py @@ -832,6 +832,9 @@ class CroniterTest(base.TestCase): ts = "{0}".format(datetime.utcfromtimestamp(c.get_prev())) self.assertEqual(ts, '2018-01-01 10:00:00') + def test_invalid_zerorepeat(self): + self.assertFalse(croniter.is_valid('*/0 * * * *')) + if __name__ == '__main__': unittest.main() |