Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29808

Re: A dateutil error has appeared, due to updates? How to fix?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'attribute': 0.05; 'fixes': 0.05; 'skip:" 60': 0.05; 'sys': 0.05; 'rename': 0.07; 'subject:How': 0.09; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:error': 0.11; "'from": 0.16; 'meanwhile': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'released.': 0.16; 'wrote:': 0.17; 'module': 0.19; 'import': 0.21; 'delta': 0.22; 'somewhere': 0.24; 'script': 0.24; 'header:User-Agent:1': 0.26; 'skip:" 20': 0.26; '(most': 0.27; 'skip:e 30': 0.27; 'skip:e 40': 0.27; 'to?': 0.27; 'header:X-Complaints-To:1': 0.28; 'diagnose': 0.29; 'probably': 0.29; "i'm": 0.29; 'code': 0.31; '(and': 0.32; 'file': 0.32; 'print': 0.32; 'getting': 0.33; 'traceback': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'changed': 0.34; 'done': 0.34; 'subject:?': 0.35; 'continue': 0.35; 'something': 0.35; 'next': 0.35; 'add': 0.36; 'received:org': 0.36; 'should': 0.36; 'uses': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'lost': 0.60; 'subject:, ': 0.61; 'repeat': 0.62; 'skip:n 10': 0.63; 'touch': 0.69; 'day': 0.73; 'directory:': 0.84; 'skip:/ 30': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: A dateutil error has appeared, due to updates? How to fix?
Date Sun, 23 Sep 2012 13:38:15 +0200
Organization None
References <vj43j9-df9.ln1@chris.zbmc.eu>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084b254.dip.t-dialin.net
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1116.1348400237.27098.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348400237 news.xs4all.nl 6975 [2001:888:2000:d::a6]:58839
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29808

Show key headers only | View raw


tinnews@isbd.co.uk wrote:

> I have a python script which uses the dateutil module with the
> following:-
> 
>     import sys
>     import datetime
>     import icalendar
>     from dateutil.relativedelta import relativedelta
> 
> The section of code which uses relativedelta is as follows:-
> 
>         #
>         #
>         # If the event is a repeating event with a start date in the
>         # past then we add the repeat interval until we find the next
>         # occurrence
>         #
>         if eventDate < datetime.date.today():
>             if event.has_key('RRULE'):
>                 freq = event.decoded('RRULE')['FREQ'][0]
>                 if event.decoded('RRULE').has_key('INTERVAL'):
>                     interval = event.decoded('RRULE')['INTERVAL'][0]
>                 else:
>                     interval = 1;
>                 if 'WEEKLY' == freq:
>                     delta = relativedelta(weeks=+interval)
>                 if 'MONTHLY' == freq:
>                     delta = relativedelta(months=+interval)
>                 if 'YEARLY' == freq:
>                     delta = relativedelta(years=+interval)
>                 while eventDate < datetime.date.today():
>                     eventDate += delta
>             else:
>                 continue        # if it's a non-repeating event in the
>                 past
> 
> 
> It used to work and all I have done meanwhile is to update my xubuntu
> system as fixes are released.  I'm now getting the error:-
> 
>     Traceback (most recent call last):
>       File "/home/chris/bin/calics.py", line 62, in <module>
>         eventDate += delta
>       File "/usr/lib/python2.7/dist-packages/dateutil/relativedelta.py",
>       line 261, in __radd__
>         day = min(calendar.monthrange(year, month)[1],
>     AttributeError: 'module' object has no attribute 'monthrange'
> 
> Have I lost a module somewhere in the updates or has something in
> python changed such that my code no longer works as it used to?
> 
> Can anyone help diagnose this please.

You probably have a file named calendar.py in your working directory:

$ python -c 'from dateutil.relativedelta import calendar; print 
calendar.__file__'
/usr/lib/python2.7/calendar.pyc
$ touch calendar.py
$ python -c 'from dateutil.relativedelta import calendar; print 
calendar.__file__'
calendar.py

Rename calendar.py in your working directory (and don't forget to delete the 
corresponding calendar.pyc) -- and dateutil should work again.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A dateutil error has appeared, due to updates?  How to fix? tinnews@isbd.co.uk - 2012-09-23 11:24 +0100
  Re: A dateutil error has appeared, due to updates?  How to fix? Peter Otten <__peter__@web.de> - 2012-09-23 13:38 +0200
    Re: A dateutil error has appeared, due to updates?  How to fix? tinnews@isbd.co.uk - 2012-09-23 16:26 +0100

csiph-web