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
15989a9f
Commit
15989a9f
authored
Sep 18, 2016
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28189: dictitems_contains no longer swallows compare errors.
(Patch by Xiang Zhang)
parent
a44cc3cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletion
+30
-1
Lib/test/test_dictviews.py
Lib/test/test_dictviews.py
+26
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/dictobject.c
Objects/dictobject.c
+1
-1
No files found.
Lib/test/test_dictviews.py
View file @
15989a9f
...
...
@@ -209,6 +209,32 @@ class DictSetTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
copy
.
copy
,
d
.
values
())
self
.
assertRaises
(
TypeError
,
copy
.
copy
,
d
.
items
())
def
test_compare_error
(
self
):
class
Exc
(
Exception
):
pass
class
BadEq
:
def
__hash__
(
self
):
return
7
def
__eq__
(
self
,
other
):
raise
Exc
k1
,
k2
=
BadEq
(),
BadEq
()
v1
,
v2
=
BadEq
(),
BadEq
()
d
=
{
k1
:
v1
}
self
.
assertIn
(
k1
,
d
)
self
.
assertIn
(
k1
,
d
.
keys
())
self
.
assertIn
(
v1
,
d
.
values
())
self
.
assertIn
((
k1
,
v1
),
d
.
items
())
self
.
assertRaises
(
Exc
,
d
.
__contains__
,
k2
)
self
.
assertRaises
(
Exc
,
d
.
keys
().
__contains__
,
k2
)
self
.
assertRaises
(
Exc
,
d
.
items
().
__contains__
,
(
k2
,
v1
))
self
.
assertRaises
(
Exc
,
d
.
items
().
__contains__
,
(
k1
,
v2
))
with
self
.
assertRaises
(
Exc
):
v2
in
d
.
values
()
def
test_pickle
(
self
):
d
=
{
1
:
10
,
"a"
:
"ABC"
}
for
proto
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
...
...
Misc/NEWS
View file @
15989a9f
...
...
@@ -19,6 +19,9 @@ Core and Builtins
-
Issue
#
25758
:
Prevents
zipimport
from
unnecessarily
encoding
a
filename
(
patch
by
Eryk
Sun
)
-
Issue
#
28189
:
dictitems_contains
no
longer
swallows
compare
errors
.
(
Patch
by
Xiang
Zhang
)
-
Issue
#
27812
:
Properly
clear
out
a
generator
's frame'
s
backreference
to
the
generator
to
prevent
crashes
in
frame
.
clear
().
...
...
Objects/dictobject.c
View file @
15989a9f
...
...
@@ -3654,7 +3654,7 @@ dictitems_contains(_PyDictViewObject *dv, PyObject *obj)
return
0
;
key
=
PyTuple_GET_ITEM
(
obj
,
0
);
value
=
PyTuple_GET_ITEM
(
obj
,
1
);
found
=
PyDict_GetItem
((
PyObject
*
)
dv
->
dv_dict
,
key
);
found
=
PyDict_GetItem
WithError
((
PyObject
*
)
dv
->
dv_dict
,
key
);
if
(
found
==
NULL
)
{
if
(
PyErr_Occurred
())
return
-
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