mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
bpo-31222: Make (datetime|date|time).replace return subclass type in Pure Python (#4176)
This commit is contained in:
parent
72fa3014d5
commit
191e993365
2 changed files with 17 additions and 3 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue