job.frequency() throws Exception, when month or weekday are specified in string ranges

Bug #1264512 reported by Harun Prasad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-crontab
Fix Released
High
Harun Prasad

Bug Description

Calling Frequency function on a CronItem throws error when the month or day of the week are specified in string ranges like JAN-MAR or MON-FRI. Below is an example.

>>> from crontab import CronTab
>>> cron = CronTab()
>>> job = cron.new()
>>> job.setall('*/15 15 * * MON-FRI')
True
>>> job.frequency()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/crontab.py", line 491, in frequency
    return self.frequency_per_year() * self.frequency_per_day()
  File "/usr/lib/python2.6/site-packages/crontab.py", line 501, in frequency_per_year
    weekdays = list(self[4])
  File "/usr/lib/python2.6/site-packages/crontab.py", line 733, in __iter__
    for bit in part.range():
  File "/usr/lib/python2.6/site-packages/crontab.py", line 861, in range
    return range(self.vfrom, self.vto+1, self.seq)
TypeError: unsupported operand type(s) for +: 'CronValue' and 'int'
>>>

Attached is the patch for this bug.

Revision history for this message
Harun Prasad (harun-b) wrote :
Revision history for this message
Martin Owens (doctormo) wrote :

I've committed r76 which contains a test which show the failure before the fix and that the fix works afterwords.

Changed in python-crontab:
milestone: none → 1.7
assignee: nobody → Harun Prasad (harun-b)
importance: Undecided → High
status: New → In Progress
status: In Progress → Fix Committed
Martin Owens (doctormo)
Changed in python-crontab:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.