Fixes endpoint checking during CronTab creation

* Fixes bug #16
This commit is contained in:
Josiah Carlson 2016-01-29 22:28:58 -08:00
parent 5bc277a425
commit df297e2f21
4 changed files with 13 additions and 3 deletions

View file

@ -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).

View file

@ -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):

View file

@ -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,

View file

@ -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 * * * *')