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
1b5f9c96
Commit
1b5f9c96
authored
Aug 31, 2018
by
Naris R
Committed by
Raymond Hettinger
Aug 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34427: Fix infinite loop when calling MutableSequence.extend() on self (GH-8813)
parent
e6dac007
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
Lib/_collections_abc.py
Lib/_collections_abc.py
+2
-0
Lib/test/test_collections.py
Lib/test/test_collections.py
+12
-0
Misc/NEWS.d/next/Library/2018-08-20-13-53-10.bpo-34427.tMRQjl.rst
...S.d/next/Library/2018-08-20-13-53-10.bpo-34427.tMRQjl.rst
+1
-0
No files found.
Lib/_collections_abc.py
View file @
1b5f9c96
...
...
@@ -986,6 +986,8 @@ class MutableSequence(Sequence):
def
extend
(
self
,
values
):
'S.extend(iterable) -- extend sequence by appending elements from the iterable'
if
values
is
self
:
values
=
list
(
values
)
for
v
in
values
:
self
.
append
(
v
)
...
...
Lib/test/test_collections.py
View file @
1b5f9c96
...
...
@@ -1721,6 +1721,18 @@ class TestCollectionABCs(ABCTestCase):
mss
.
clear
()
self
.
assertEqual
(
len
(
mss
),
0
)
# issue 34427
# extending self should not cause infinite loop
items
=
'ABCD'
mss2
=
MutableSequenceSubclass
()
mss2
.
extend
(
items
+
items
)
mss
.
clear
()
mss
.
extend
(
items
)
mss
.
extend
(
mss
)
self
.
assertEqual
(
len
(
mss
),
len
(
mss2
))
self
.
assertEqual
(
list
(
mss
),
list
(
mss2
))
################################################################################
### Counter
################################################################################
...
...
Misc/NEWS.d/next/Library/2018-08-20-13-53-10.bpo-34427.tMRQjl.rst
0 → 100644
View file @
1b5f9c96
Fix infinite loop in ``a.extend(a)`` for ``MutableSequence`` subclasses.
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