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
c79447b2
Commit
c79447b2
authored
Sep 27, 2015
by
Alexander Belopolsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes issue #23600: Wrong results from tzinfo.fromutc().
parent
87d0066f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
Lib/test/datetimetester.py
Lib/test/datetimetester.py
+23
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_datetimemodule.c
Modules/_datetimemodule.c
+1
-1
No files found.
Lib/test/datetimetester.py
View file @
c79447b2
...
...
@@ -180,6 +180,29 @@ class TestTZInfo(unittest.TestCase):
self
.
assertEqual
(
derived
.
utcoffset
(
None
),
offset
)
self
.
assertEqual
(
derived
.
tzname
(
None
),
oname
)
def
test_issue23600
(
self
):
DSTDIFF
=
DSTOFFSET
=
timedelta
(
hours
=
1
)
class
UKSummerTime
(
tzinfo
):
"""Simple time zone which pretends to always be in summer time, since
that's what shows the failure.
"""
def
utcoffset
(
self
,
dt
):
return
DSTOFFSET
def
dst
(
self
,
dt
):
return
DSTDIFF
def
tzname
(
self
,
dt
):
return
'UKSummerTime'
tz
=
UKSummerTime
()
u
=
datetime
(
2014
,
4
,
26
,
12
,
1
,
tzinfo
=
tz
)
t
=
tz
.
fromutc
(
u
)
self
.
assertEqual
(
t
-
t
.
utcoffset
(),
u
)
class
TestTimeZone
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Misc/NEWS
View file @
c79447b2
...
...
@@ -81,6 +81,9 @@ Core and Builtins
Library
-------
-
Issue
#
23600
:
Default
implementation
of
tzinfo
.
fromutc
()
was
returning
wrong
results
in
some
cases
.
-
Prevent
overflow
in
_Unpickler_Read
.
-
Issue
#
25047
:
The
XML
encoding
declaration
written
by
Element
Tree
now
...
...
Modules/_datetimemodule.c
View file @
c79447b2
...
...
@@ -3040,7 +3040,7 @@ tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt)
goto
Fail
;
if
(
dst
==
Py_None
)
goto
Inconsistent
;
if
(
delta_bool
(
delta
)
!=
0
)
{
if
(
delta_bool
(
(
PyDateTime_Delta
*
)
dst
)
!=
0
)
{
PyObject
*
temp
=
result
;
result
=
add_datetime_timedelta
((
PyDateTime_DateTime
*
)
result
,
(
PyDateTime_Delta
*
)
dst
,
1
);
...
...
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