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
f8de3fea
Commit
f8de3fea
authored
Dec 03, 2010
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#10360: catch TypeError in WeakSet.__contains__, just like WeakKeyDictionary does.
parent
3b9406b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
2 deletions
+10
-2
Lib/_weakrefset.py
Lib/_weakrefset.py
+5
-1
Lib/test/test_weakset.py
Lib/test/test_weakset.py
+2
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/_weakrefset.py
View file @
f8de3fea
...
...
@@ -66,7 +66,11 @@ class WeakSet:
return
sum
(
x
()
is
not
None
for
x
in
self
.
data
)
def
__contains__
(
self
,
item
):
return
ref
(
item
)
in
self
.
data
try
:
wr
=
ref
(
item
)
except
TypeError
:
return
False
return
wr
in
self
.
data
def
__reduce__
(
self
):
return
(
self
.
__class__
,
(
list
(
self
),),
...
...
Lib/test/test_weakset.py
View file @
f8de3fea
...
...
@@ -50,7 +50,8 @@ class TestWeakSet(unittest.TestCase):
def
test_contains
(
self
):
for
c
in
self
.
letters
:
self
.
assertEqual
(
c
in
self
.
s
,
c
in
self
.
d
)
self
.
assertRaises
(
TypeError
,
self
.
s
.
__contains__
,
[[]])
# 1 is not weakref'able, but that TypeError is caught by __contains__
self
.
assertNotIn
(
1
,
self
.
s
)
self
.
assertIn
(
self
.
obj
,
self
.
fs
)
del
self
.
obj
self
.
assertNotIn
(
ustr
(
'F'
),
self
.
fs
)
...
...
Misc/NEWS
View file @
f8de3fea
...
...
@@ -33,6 +33,9 @@ Core and Builtins
Library
-------
- Issue #10360: In WeakSet, do not raise TypeErrors when testing for
membership of non-weakrefable objects.
- Issue #940286: pydoc.Helper.help() ignores input/output init parameters.
- Issue #1745035: Add a command size and data size limit to smtpd.py, to
...
...
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