rrule brocken when cache used by using _thread module in Python2

Bug #1378220 reported by SteffenOschatz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
Fix Released
Undecided
Unassigned
python-dateutil (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Upgraded Ubuntu from 12.04 to 14.04, so a new version was installed (Version: 1.5+dfsg-1ubuntu1) and I assume a new Python version too (2.7.6) .
With the new versions following traceback appears:

    dates = list(rrule(DAILY, count=count, dtstart=now(tz), cache=True))
  File "/usr/local/lib/python2.7/dist-packages/dateutil/rrule.py", line 239, in __init__
    super(rrule, self).__init__(cache)
  File "/usr/local/lib/python2.7/dist-packages/dateutil/rrule.py", line 90, in __init__
    self._cache_lock = _thread.allocate_lock()
AttributeError: 'module' object has no attribute 'allocate_lock'

Tracked it down to the cache parameter.
Last known working version seems to be 1.5 , so all following versions are broken too up to the newest (2.2).

If I should guess, than these import of the _thread was introduced for Python3 - right ?
But the problem is: these module is also available in Python2 - at least in the 2.7.6 where there is no 'allocate_lock' .

So the "optimistic" try/except approach regarding of the import of the thread module should be replaced with a version check or attribute check instead.

Revision history for this message
SteffenOschatz (steffen-oschatz) wrote :

Reproducible by, for example:

from dateutil.rrule import rrule, DAILY
list(rrule(DAILY, count=7, cache=True)

Revision history for this message
SteffenOschatz (steffen-oschatz) wrote :

I thought that there maybe are no tests for it - but they are.
Running test.py with python 2.7.6 also shows these errors beside others (TZTest).
But while running tox, only the failed TZTests are shown.
So these maybe is the reason why it was not detected while it was introduced already 2/3 years ago.

Revision history for this message
jarondl (jarondl) wrote :

This bug was fixed on version 2.3 (released on PyPI)
Please try the new version, and if the bug persists, open a new github issue

jarondl (jarondl)
Changed in dateutil:
status: New → Fix Released
Revision history for this message
SteffenOschatz (steffen-oschatz) wrote :

Thanks! Works for me.

Changed in python-dateutil (Ubuntu):
status: New → 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.