Odd behavior in timesince and timeuntil methods
|Reported by:||jcarbaugh||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This issue was raised while fixing #7201.
The timesince and timeuntil methods exhibit odd behavior if two arguments are passed and only one has tzinfo. Prior to #7201, the tzinfo of the first argument would be given to the second argument. This would cause the correct tzinfo of the second argument to be overwritten and the incorrect value returned from the method.
The fix for #7201 maintains this behavior but extends it so that if only one argument has tzinfo it will be applied to the argument without tzinfo. tzinfo will not be overwritten if null. The behavior was maintained because it would be backwards incompatible if changed.
This raises the issue of whether any timezone should be assumed or if an error should be raised. Python would normally throw a TypeError when operating on offset-naive and offset-aware datetimes. It seems as if the methods should allow the TypeError to be raised rather than making a timezone assumption.