diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-10 00:52:05 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-11-10 00:52:05 (GMT) |
commit | b9a40aca2935d2569191844c88f8b61269e383cb (patch) | |
tree | 77d18498d553e8369c34724371ec7c681daf4e2f /Lib/datetime.py | |
parent | 596286f8f3c8e53ef010d6298464775dc900a515 (diff) | |
download | cpython-b9a40aca2935d2569191844c88f8b61269e383cb.zip cpython-b9a40aca2935d2569191844c88f8b61269e383cb.tar.gz cpython-b9a40aca2935d2569191844c88f8b61269e383cb.tar.bz2 |
bpo-31222: Make (datetime|date|time).replace return subclass type in Pure Python (GH-4176) (#4356)
(cherry picked from commit 191e993365ac3206f46132dcf46236471ec54bfa)
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 b95536f..150664e 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -827,7 +827,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. @@ -1315,7 +1315,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. @@ -1596,7 +1596,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): |