This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2017年09月27日 10:43 by Oren Milman, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| 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 _collections class 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() (in Modules/_collectionsmodule.c) returns whatever BadDeque() returned, without verifying it is a deque. deque_repeat() assumes that deque_copy() returned a deque, and passes it to deque_inplace_repeat(), which assumes it is a deque, and crashes. (Similarly, deque_concat() assumes that deque_copy() returned a deque, which is the reason for the other crash.) ISTM it is a very unlikely corner case, so that adding a test (as well as a NEWS.d item) for it is unnecessary. What do you think? |
|||
| msg303133 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | 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) * (Python committer) | 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) * (Python committer) | Date: 2018年09月11日 18:46 | |
New changeset 24bd50bdcc97d65130c07d6cd26085fd06c3e972 by Benjamin Peterson (Oren Milman) in branch 'master': closes bpo-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 changeset 536e45accf8f05355dd943a6966b9968cdb15f5a by Miss Islington (bot) in branch '3.7': closes bpo-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) * (Python committer) | Date: 2018年09月11日 19:12 | |
New changeset ccbbdd0a1e00ecad6f0005438dd6ff6d84fd9ceb by Benjamin Peterson in branch '3.6': [3.6] closes bpo-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) * (Python committer) | Date: 2018年09月11日 20:42 | |
New changeset 253279c616d4f34287c5749df15e20eb2eb988d6 by Benjamin Peterson in branch '2.7': [2.7] closes bpo-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 | |