
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-09-27 10:43 byOren Milman, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 3788 | merged | Oren Milman,2017-09-27 11:17 | |
| PR 9177 | merged | miss-islington,2018-09-11 18:47 | |
| PR 9179 | merged | benjamin.peterson,2018-09-11 19:01 | |
| PR 9178 | merged | benjamin.peterson,2020-12-08 13:23 | |
| Messages (7) | |||
|---|---|---|---|
| msg303125 -(view) | Author: Oren Milman (Oren Milman)* | Date: 2017-09-27 10:43 | |
The following code causes the interpreter to crash:import _collectionsclass BadDeque(_collections.deque): def __new__(cls, *args): if len(args): return 42 return _collections.deque.__new__(cls)BadDeque() * 42(The interpreter would crash also if we replaced 'BadDeque() * 42' with'BadDeque() + _collections.deque([42])'.)This is because deque_copy() (inModules/_collectionsmodule.c) returns whateverBadDeque() returned, without verifying it is a deque.deque_repeat() assumes that deque_copy() returned a deque, and passes it todeque_inplace_repeat(), which assumes it is a deque, and crashes.(Similarly, deque_concat() assumes that deque_copy() returned a deque, whichis the reason for the other crash.)ISTM it is a very unlikely corner case, so that adding a test (as well asa NEWS.d item) for it is unnecessary.What do you think? | |||
| msg303133 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-09-27 12:58 | |
All other sequence objects return an instance of the base class rather than a subclass. list, tuple, str, bytes, bytearray, array. Only deque tries to create an instance of a subclass. | |||
| msg304000 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-10-09 20:53 | |
I meant that if make deque.copy(), deque.__add__() and deque.__mul__() returning an exact deque for subclasses, this would make the deque class more consistent with other collections and solve this issue. This could even make them (almost) atomic. | |||
| msg325049 -(view) | Author: Benjamin Peterson (benjamin.peterson)*![]() | Date: 2018-09-11 18:46 | |
New changeset24bd50bdcc97d65130c07d6cd26085fd06c3e972 by Benjamin Peterson (Oren Milman) in branch 'master':closesbpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-3788)https://github.com/python/cpython/commit/24bd50bdcc97d65130c07d6cd26085fd06c3e972 | |||
| msg325054 -(view) | Author: miss-islington (miss-islington) | Date: 2018-09-11 19:08 | |
New changeset536e45accf8f05355dd943a6966b9968cdb15f5a by Miss Islington (bot) in branch '3.7':closesbpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-3788)https://github.com/python/cpython/commit/536e45accf8f05355dd943a6966b9968cdb15f5a | |||
| msg325055 -(view) | Author: Benjamin Peterson (benjamin.peterson)*![]() | Date: 2018-09-11 19:12 | |
New changesetccbbdd0a1e00ecad6f0005438dd6ff6d84fd9ceb by Benjamin Peterson in branch '3.6':[3.6] closesbpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-9178)https://github.com/python/cpython/commit/ccbbdd0a1e00ecad6f0005438dd6ff6d84fd9ceb | |||
| msg325057 -(view) | Author: Benjamin Peterson (benjamin.peterson)*![]() | Date: 2018-09-11 20:42 | |
New changeset253279c616d4f34287c5749df15e20eb2eb988d6 by Benjamin Peterson in branch '2.7':[2.7] closesbpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-9179)https://github.com/python/cpython/commit/253279c616d4f34287c5749df15e20eb2eb988d6 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75789 |
| 2020-12-08 13:23:48 | benjamin.peterson | set | pull_requests: +pull_request22560 |
| 2018-09-11 20:42:01 | benjamin.peterson | set | messages: +msg325057 |
| 2018-09-11 19:12:46 | benjamin.peterson | set | messages: +msg325055 |
| 2018-09-11 19:08:15 | miss-islington | set | nosy: +miss-islington messages: +msg325054 |
| 2018-09-11 19:01:38 | benjamin.peterson | set | pull_requests: +pull_request8618 |
| 2018-09-11 18:47:08 | miss-islington | set | pull_requests: +pull_request8616 |
| 2018-09-11 18:46:58 | benjamin.peterson | set | status: open -> closed nosy: +benjamin.peterson messages: +msg325049 resolution: fixed stage: patch review -> resolved |
| 2017-10-09 20:53:19 | serhiy.storchaka | set | messages: +msg304000 |
| 2017-09-27 12:58:18 | serhiy.storchaka | set | versions: + Python 2.7, Python 3.6 nosy: +serhiy.storchaka,rhettinger messages: +msg303133 assignee:rhettinger |
| 2017-09-27 11:17:49 | Oren Milman | set | keywords: +patch stage: patch review pull_requests: +pull_request3774 |
| 2017-09-27 10:43:58 | Oren Milman | create | |