classification
Title: del list[a:b:c] doesn't handle correctly list_resize() failure
Type: Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, serhiy.storchaka, skrah, vstinner
Priority: normal Keywords: patch

Created on 2013-11-14 00:42 by vstinner, last changed 2013-11-21 11:16 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
list_ass_subscript.patch vstinner, 2013-11-14 00:42
Messages (4)
msg202808 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-14 00:42
"del list[start:stop:step]" instruction doesn't handle list_resize() failure when step != 1.

Attached patch notifies the caller that list_resize() fails. On case of failure, the list is modified (items are deleted), it's just that list buffer could be smaller (it wastes memory).

See also issue #19568 which is similar for bytearray.
msg203446 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-19 23:55
Hum, my explanation is maybe not clear.

Without the patch, the operation succeed, but a MemoryError is raised, and the caller is not notified. So you enter an inconsistent state because your function may "succeed" whereas an exception is set.

With the patch, the operation succeed, but you get a MemoryError and the caller is notified of the failure.
msg203600 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-21 10:05
The patch is very simple and LGTM.
msg203611 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-21 11:16
New changeset b508253f2876 by Victor Stinner in branch 'default':
Close #19578: Fix list_ass_subscript(), handle list_resize() failure
http://hg.python.org/cpython/rev/b508253f2876
History
Date User Action Args
2013-11-21 11:16:51python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg203611

resolution: fixed
stage: resolved
2013-11-21 10:05:25serhiy.storchakasetmessages: + msg203600
2013-11-19 23:55:27vstinnersetmessages: + msg203446
2013-11-19 21:25:21vstinnersetnosy: + skrah
2013-11-14 00:42:25vstinnersetnosy: + serhiy.storchaka
2013-11-14 00:42:00vstinnercreate