bpo-31222: Make (datetime|date|time).replace return subclass type in … · python/cpython@191e993
@@ -828,7 +828,7 @@ def replace(self, year=None, month=None, day=None):
828828month = self._month
829829if day is None:
830830day = self._day
831-return date(year, month, day)
831+return type(self)(year, month, day)
832832833833# Comparisons of date objects with other.
834834@@ -1316,7 +1316,7 @@ def replace(self, hour=None, minute=None, second=None, microsecond=None,
13161316tzinfo = self.tzinfo
13171317if fold is None:
13181318fold = self._fold
1319-return time(hour, minute, second, microsecond, tzinfo, fold=fold)
1319+return type(self)(hour, minute, second, microsecond, tzinfo, fold=fold)
1320132013211321# Pickle support.
13221322@@ -1597,7 +1597,7 @@ def replace(self, year=None, month=None, day=None, hour=None,
15971597tzinfo = self.tzinfo
15981598if fold is None:
15991599fold = self.fold
1600-return datetime(year, month, day, hour, minute, second,
1600+return type(self)(year, month, day, hour, minute, second,
16011601microsecond, tzinfo, fold=fold)
1602160216031603def _local_timezone(self):