Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21256 closed Bug (fixed)

Error in django.utils.datetime_safe.datetime.combine method

Reported by: Łukasz Owned by: nobody
Component: Utilities Version: 1.5
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There seems to be an error in the combine() method of the django.utils.datetime_safe.datetime class. Current definition:

    def combine(self, date, time):
        return datetime(date.year, date.month, date.day, time.hour, time.minute, time.microsecond, time.tzinfo)

The time.second value is not passed to the datetime constructor. Moreover, this method should be a classmethod, like so:

    @classmethod
    def combine(cls, date, time):
        return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond, time.tzinfo)

Change History (5)

comment:1 by Aymeric Augustin, 11 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

This bug has been corrupting data since #1443 was fixed, more than five years ago. It's interesting that it wasn't detected earlier.

(FWIW I don't really like datetime_safe.)

Since the fix is really trivial and it's a data corruption bug, I'm going to backport the fix back to 1.4.

comment:2 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

Resolution: fixed
Status: newclosed

In d9b6fb8f61e5029ce5d45d8fcb75694cee046b8f:

Fixed #21256 -- Error in datetime_safe.datetime.combine.

comment:3 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In ef9133768c2aed52646ad0b6274edf836aa672b2:

[1.5.x] Fixed #21256 -- Error in datetime_safe.datetime.combine.

Backport of d9b6fb8 from master

comment:4 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In ea04c81d372aaa1b1aebdacefc46735ef9559fb6:

[1.4.x] Fixed #21256 -- Error in datetime_safe.datetime.combine.

Backport of d9b6fb8 from master

comment:5 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 5591fe6829c458346982e39e777f1fdca69e9792:

[1.6.x] Fixed #21256 -- Error in datetime_safe.datetime.combine.

Backport of d9b6fb8 from master

Note: See TracTickets for help on using tickets.
Back to Top