Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e8751e05
Commit
e8751e05
authored
May 10, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #14157: Fix time.strptime failing without a year on February 29th.
Patch by Hynek Schlawack.
parents
59d5404b
1682e5d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
Lib/_strptime.py
Lib/_strptime.py
+5
-1
Lib/test/test_strptime.py
Lib/test/test_strptime.py
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/_strptime.py
View file @
e8751e05
...
@@ -339,7 +339,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
...
@@ -339,7 +339,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
raise ValueError("
unconverted
data
remains
:
%
s
" %
raise ValueError("
unconverted
data
remains
:
%
s
" %
data_string[found.end():])
data_string[found.end():])
year =
1900
year =
None
month = day = 1
month = day = 1
hour = minute = second = fraction = 0
hour = minute = second = fraction = 0
tz = -1
tz = -1
...
@@ -444,6 +444,10 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
...
@@ -444,6 +444,10 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
else:
else:
tz = value
tz = value
break
break
if year is None and month == 2 and day == 29:
year = 1904 # 1904 is first leap year of 20th century
elif year is None:
year = 1900
# If we know the week of the year and what day of that week, we can figure
# If we know the week of the year and what day of that week, we can figure
# out the Julian day of the year.
# out the Julian day of the year.
if julian == -1 and week_of_year != -1 and weekday != -1:
if julian == -1 and week_of_year != -1 and weekday != -1:
...
...
Lib/test/test_strptime.py
View file @
e8751e05
...
@@ -378,6 +378,9 @@ class StrptimeTests(unittest.TestCase):
...
@@ -378,6 +378,9 @@ class StrptimeTests(unittest.TestCase):
need_escaping = "
.
^
$
*+
?
{}
\
[]
|
)(
"
need_escaping = "
.
^
$
*+
?
{}
\
[]
|
)(
"
self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping))
self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping))
def test_feb29_on_leap_year_without_year(self):
time.strptime("
Feb
29
", "
%
b
%
d
")
class Strptime12AMPMTests(unittest.TestCase):
class Strptime12AMPMTests(unittest.TestCase):
"""Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
"""Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
...
...
Misc/NEWS
View file @
e8751e05
...
@@ -23,6 +23,9 @@ Core and Builtins
...
@@ -23,6 +23,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #14157: Fix time.strptime failing without a year on February 29th.
Patch by Hynek Schlawack.
- Issue #14753: Make multiprocessing'
s
handling
of
negative
timeouts
- Issue #14753: Make multiprocessing'
s
handling
of
negative
timeouts
the
same
as
it
was
in
Python
3.2
.
the
same
as
it
was
in
Python
3.2
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment