diff options
author | Paul Ganssle <pganssle@users.noreply.github.com> | 2017-11-09 21:34:29 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-11-09 21:34:29 (GMT) |
commit | 191e993365ac3206f46132dcf46236471ec54bfa (patch) | |
tree | 56093f01ed019b5b0d6e3c6b5bc4600721b8438f /Lib/datetime.py | |
parent | 72fa3014d5afa5e9ee407dee132991185da33c10 (diff) | |
download | cpython-191e993365ac3206f46132dcf46236471ec54bfa.zip cpython-191e993365ac3206f46132dcf46236471ec54bfa.tar.gz cpython-191e993365ac3206f46132dcf46236471ec54bfa.tar.bz2 |
bpo-31222: Make (datetime|date|time).replace return subclass type in Pure Python (#4176)
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r-- | Lib/datetime.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py index 2f03847..67d8600 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -828,7 +828,7 @@ class date: month = self._month if day is None: day = self._day - return date(year, month, day) + return type(self)(year, month, day) # Comparisons of date objects with other. @@ -1316,7 +1316,7 @@ class time: tzinfo = self.tzinfo if fold is None: fold = self._fold - return time(hour, minute, second, microsecond, tzinfo, fold=fold) + return type(self)(hour, minute, second, microsecond, tzinfo, fold=fold) # Pickle support. @@ -1597,7 +1597,7 @@ class datetime(date): tzinfo = self.tzinfo if fold is None: fold = self.fold - return datetime(year, month, day, hour, minute, second, + return type(self)(year, month, day, hour, minute, second, microsecond, tzinfo, fold=fold) def _local_timezone(self): |