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
0085a240
Commit
0085a240
authored
Sep 22, 2012
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes #15973: fix a segmentation fault when comparing timezone objects.
parent
fd296ff5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/datetime.py
Lib/datetime.py
+2
-0
Lib/test/datetimetester.py
Lib/test/datetimetester.py
+2
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_datetimemodule.c
Modules/_datetimemodule.c
+6
-0
No files found.
Lib/datetime.py
View file @
0085a240
...
...
@@ -1854,6 +1854,8 @@ class timezone(tzinfo):
return
(
self
.
_offset
,
self
.
_name
)
def
__eq__
(
self
,
other
):
if
type
(
other
)
!=
timezone
:
return
False
return
self
.
_offset
==
other
.
_offset
def
__hash__
(
self
):
...
...
Lib/test/datetimetester.py
View file @
0085a240
...
...
@@ -235,6 +235,8 @@ class TestTimeZone(unittest.TestCase):
self
.
assertEqual
(
timezone
(
-
5
*
HOUR
),
timezone
(
-
5
*
HOUR
,
'EST'
))
with
self
.
assertRaises
(
TypeError
):
timezone
(
ZERO
)
<
timezone
(
ZERO
)
self
.
assertIn
(
timezone
(
ZERO
),
{
timezone
(
ZERO
)})
self
.
assertTrue
(
timezone
(
ZERO
)
!=
None
)
self
.
assertFalse
(
timezone
(
ZERO
)
==
None
)
def
test_aware_datetime
(
self
):
# test that timezone instances can be used by datetime
...
...
Misc/NEWS
View file @
0085a240
...
...
@@ -31,6 +31,9 @@ Library
Extension Modules
-----------------
- Issue #15973: Fix a segmentation fault when comparing datetime timezone
objects.
- Issue #15977: Fix memory leak in Modules/_ssl.c when the function
_set_npn_protocols() is called multiple times, thanks to Daniel Sommermann.
...
...
Modules/_datetimemodule.c
View file @
0085a240
...
...
@@ -3215,6 +3215,12 @@ timezone_richcompare(PyDateTime_TimeZone *self,
{
if
(
op
!=
Py_EQ
&&
op
!=
Py_NE
)
Py_RETURN_NOTIMPLEMENTED
;
if
(
Py_TYPE
(
other
)
!=
&
PyDateTime_TimeZoneType
)
{
if
(
op
==
Py_EQ
)
Py_RETURN_FALSE
;
else
Py_RETURN_TRUE
;
}
return
delta_richcompare
(
self
->
offset
,
other
->
offset
,
op
);
}
...
...
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