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
3a624042
Commit
3a624042
authored
Nov 08, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly forward exception in instance_contains().
Fixes #1591996. Patch contributed by Neal Norwitz. Will backport.
parent
e452f51b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
Lib/test/test_class.py
Lib/test/test_class.py
+8
-0
Objects/classobject.c
Objects/classobject.c
+6
-4
No files found.
Lib/test/test_class.py
View file @
3a624042
...
...
@@ -172,6 +172,14 @@ testme ^ 1
# List/dict operations
class
Empty
:
pass
try
:
1
in
Empty
()
print
'failed, should have raised TypeError'
except
TypeError
:
pass
1
in
testme
testme
[
1
]
...
...
Objects/classobject.c
View file @
3a624042
...
...
@@ -1318,15 +1318,17 @@ instance_contains(PyInstanceObject *inst, PyObject *member)
/* Couldn't find __contains__. */
if
(
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
Py_ssize_t
rc
;
/* Assume the failure was simply due to that there is no
* __contains__ attribute, and try iterating instead.
*/
PyErr_Clear
();
return
_PySequence_IterSearch
((
PyObject
*
)
inst
,
member
,
PY_ITERSEARCH_CONTAINS
)
>
0
;
rc
=
_PySequence_IterSearch
((
PyObject
*
)
inst
,
member
,
PY_ITERSEARCH_CONTAINS
);
if
(
rc
>=
0
)
return
rc
>
0
;
}
else
return
-
1
;
return
-
1
;
}
static
PySequenceMethods
...
...
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