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
5b44cbe6
Commit
5b44cbe6
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
f96725af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
Lib/test/test_deque.py
Lib/test/test_deque.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/collectionsmodule.c
Modules/collectionsmodule.c
+2
-3
No files found.
Lib/test/test_deque.py
View file @
5b44cbe6
...
...
@@ -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
...
...
Misc/NEWS
View file @
5b44cbe6
...
...
@@ -129,6 +129,9 @@ Extension Modules
-
Added
support
for
linking
the
bsddb
module
against
BerkeleyDB
4.5
.
x
.
-
Modifying
an
empty
deque
during
iteration
now
raises
RuntimeError
instead
of
StopIteration
.
Library
-------
...
...
Modules/collectionsmodule.c
View file @
5b44cbe6
...
...
@@ -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