adding a datetime to a relativedelta with a non-integer month value gives a TypeError

Bug #1204017 reported by Josh
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
dateutil
New
Undecided
Unassigned

Bug Description

Adding a datetime to a relativedelta that has the months set to a non-integer value gives the following:

 TypeError: integer argument expected, got float

A similar bug is here:

 https://bugs.launchpad.net/dateutil/+bug/737099

The patch for that bug could probably be generalised to fix this same issue in the __add__, __sub__ and __neg__ methods of relativedelta as a stop-gap. But ideally one should be able to add 1.5 months to a datetime and have it return another datetime that's actually 1.5 months in the future (whatever 1.5 months might mean). Casting to an int doesn't really provide that.

Attached code reproduces the issue.

Revision history for this message
Josh (josh-crompton) wrote :
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.