Skip to content

Commit 00e3b45

Browse files
committed
minor fixes
1 parent ebaf468 commit 00e3b45

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/_pydatetime.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold
14721472
fold (keyword only, default to zero)
14731473
nanosecond (keyword only, default to zero)
14741474
"""
1475-
if (isinstance(hour, (bytes, str)) and len(hour) == 6 and
1475+
if (isinstance(hour, (bytes, str)) and len(hour) == 8 and
14761476
ord(hour[0:1])&0x7F < 24):
14771477
# Pickle support
14781478
if isinstance(hour, str):
@@ -1821,7 +1821,7 @@ class datetime(date):
18211821

18221822
def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
18231823
microsecond=0, tzinfo=None, *, fold=0, nanosecond=0):
1824-
if (isinstance(year, (bytes, str)) and len(year) == 10 and
1824+
if (isinstance(year, (bytes, str)) and len(year) == 12 and
18251825
1 <= ord(year[2:3])&0x7F <= 12):
18261826
# Pickle support
18271827
if isinstance(year, str):
@@ -1834,6 +1834,7 @@ def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
18341834
"a datetime object. "
18351835
"pickle.load(data, encoding='latin1') is assumed.")
18361836
self = object.__new__(cls)
1837+
# year is string and month is tzinfo
18371838
self.__setstate(year, month)
18381839
self._hashcode = -1
18391840
return self

0 commit comments

Comments
 (0)