[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2020-12-08 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
pull_requests: +22560
pull_request: https://github.com/python/cpython/pull/9178

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2018-09-11 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


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


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2018-09-11 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


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


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2018-09-11 Thread miss-islington


miss-islington  added the comment:


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


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2018-09-11 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
pull_requests: +8618

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2018-09-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8616

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2018-09-11 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


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


--
nosy: +benjamin.peterson
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2017-10-09 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2017-09-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

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.

--
assignee:  -> rhettinger
nosy: +rhettinger, serhiy.storchaka
versions: +Python 2.7, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2017-09-27 Thread Oren Milman

Change by Oren Milman :


--
keywords: +patch
pull_requests: +3774
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31608] crash in methods of a subclass of _collections.deque with a bad __new__()

2017-09-27 Thread Oren Milman

New submission from Oren Milman :

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?

--
components: Extension Modules
messages: 303125
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: crash in methods of a subclass of _collections.deque with a bad __new__()
type: crash
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com