From df297e2f214ec08c7807a19e6149a26f0e673fb6 Mon Sep 17 00:00:00 2001 From: Josiah Carlson Date: Fri, 29 Jan 2016 22:28:58 -0800 Subject: [PATCH] Fixes endpoint checking during CronTab creation * Fixes bug #16 --- README.rst | 2 +- crontab/_crontab.py | 6 +++++- setup.py | 3 ++- tests/test_crontab.py | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 9fbdade..56f5e17 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -Copyright 2011-2014 Josiah Carlson +Copyright 2011-2016 Josiah Carlson Released under the LGPL license version 2.1 and version 3 (you can choose which you'd like to be bound under). diff --git a/crontab/_crontab.py b/crontab/_crontab.py index 37079ee..0d65731 100644 --- a/crontab/_crontab.py +++ b/crontab/_crontab.py @@ -201,7 +201,11 @@ class _Matcher(object): return _alternate[which][it] _assert(it.isdigit(), "invalid range specifier: %r (%r)", it, entry) - return int(it, 10) + it = int(it, 10) + _assert(_start <= it <= _end_limit, + "item value %r out of range [%r, %r]", + it, _start, _end_limit) + return it # this handles individual items/ranges def _parse_piece(it): diff --git a/setup.py b/setup.py index a5dafd9..95ff6da 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except: setup( name='crontab', - version='0.20.3', + version='0.20.4', description='Parse and use crontab schedules in Python', author='Josiah Carlson', author_email='josiah.carlson@gmail.com', @@ -27,6 +27,7 @@ setup( 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', ], license='GNU LGPL v2.1', long_description=long_description, diff --git a/tests/test_crontab.py b/tests/test_crontab.py index 9742777..f9c9236 100644 --- a/tests/test_crontab.py +++ b/tests/test_crontab.py @@ -136,6 +136,11 @@ class TestCrontab(unittest.TestCase): self.assertRaises(ValueError, lambda: CronTab('* L * * *')) self.assertRaises(ValueError, lambda: CronTab('L * * * *')) self.assertRaises(ValueError, lambda: CronTab('* 1, * * *')) + self.assertRaises(ValueError, lambda: CronTab('60 * * * *')) + self.assertRaises(ValueError, lambda: CronTab('* 25 * * *')) + self.assertRaises(ValueError, lambda: CronTab('* * 32 * *')) + self.assertRaises(ValueError, lambda: CronTab('* * * 13 *')) + self.assertRaises(ValueError, lambda: CronTab('* * * * 9999')) def test_previous(self): schedule = CronTab('0 * * * *')