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
9298d7c1
Commit
9298d7c1
authored
Dec 18, 2013
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #20006: Fix sporadic failures in test_weakset.
parents
cbbbf504
d0eab622
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
Lib/_weakrefset.py
Lib/_weakrefset.py
+2
-0
Lib/test/test_weakset.py
Lib/test/test_weakset.py
+6
-2
No files found.
Lib/_weakrefset.py
View file @
9298d7c1
...
@@ -60,6 +60,8 @@ class WeakSet:
...
@@ -60,6 +60,8 @@ class WeakSet:
for
itemref
in
self
.
data
:
for
itemref
in
self
.
data
:
item
=
itemref
()
item
=
itemref
()
if
item
is
not
None
:
if
item
is
not
None
:
# Caveat: the iterator will keep a strong reference to
# `item` until it is resumed or closed.
yield
item
yield
item
def
__len__
(
self
):
def
__len__
(
self
):
...
...
Lib/test/test_weakset.py
View file @
9298d7c1
...
@@ -370,10 +370,14 @@ class TestWeakSet(unittest.TestCase):
...
@@ -370,10 +370,14 @@ class TestWeakSet(unittest.TestCase):
def
testcontext
():
def
testcontext
():
try
:
try
:
it
=
iter
(
s
)
it
=
iter
(
s
)
next
(
it
)
# Start iterator
del
it
yielded
=
ustr
(
str
(
next
(
it
)))
# Schedule an item for removal and recreate it
# Schedule an item for removal and recreate it
u
=
ustr
(
str
(
items
.
pop
()))
u
=
ustr
(
str
(
items
.
pop
()))
if
yielded
==
u
:
# The iterator still has a reference to the removed item,
# advance it (issue #20006).
next
(
it
)
gc
.
collect
()
# just in case
gc
.
collect
()
# just in case
yield
u
yield
u
finally
:
finally
:
...
...
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