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
10d4bcc0
Commit
10d4bcc0
authored
Jan 08, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix zero-length corner case for iterating over a mutating deque.
parent
0f7279b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
Lib/test/test_deque.py
Lib/test/test_deque.py
+6
-0
Modules/collectionsmodule.c
Modules/collectionsmodule.c
+2
-3
No files found.
Lib/test/test_deque.py
View file @
10d4bcc0
...
...
@@ -396,6 +396,12 @@ class TestVariousIteratorArgs(unittest.TestCase):
d
.
pop
()
self
.
assertRaises
(
RuntimeError
,
it
.
next
)
def
test_runtime_error_on_empty_deque
(
self
):
d
=
deque
()
it
=
iter
(
d
)
d
.
append
(
10
)
self
.
assertRaises
(
RuntimeError
,
it
.
next
)
class
Deque
(
deque
):
pass
...
...
Modules/collectionsmodule.c
View file @
10d4bcc0
...
...
@@ -911,15 +911,14 @@ dequeiter_next(dequeiterobject *it)
{
PyObject
*
item
;
if
(
it
->
counter
==
0
)
return
NULL
;
if
(
it
->
deque
->
state
!=
it
->
state
)
{
it
->
counter
=
0
;
PyErr_SetString
(
PyExc_RuntimeError
,
"deque mutated during iteration"
);
return
NULL
;
}
if
(
it
->
counter
==
0
)
return
NULL
;
assert
(
!
(
it
->
b
==
it
->
deque
->
rightblock
&&
it
->
index
>
it
->
deque
->
rightindex
));
...
...
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