diff options
author | Oren Milman <orenmn@gmail.com> | 2018-09-11 21:46:55 +0300 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-09-11 11:48:35 -0700 |
commit | a7c1f94b4b054ed69e873cbe3f3e528ac7cf3e5f (patch) | |
tree | e26233e193cdac999426a849c3b75a83e52bf28a /Lib/test | |
parent | 889f080a4d5cdb1cfb901b953f4b89f3ea806bbe (diff) | |
download | cpython-git-backport-24bd50b-3.6.tar.gz |
[3.6] closes bpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-3788).backport-24bd50b-3.6
(cherry picked from commit 24bd50bdcc97d65130c07d6cd26085fd06c3e972)
Co-authored-by: Oren Milman <orenmn@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_deque.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index ce517b51d5..ed9ea0251a 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -893,6 +893,21 @@ class TestSubclass(unittest.TestCase): d1 == d2 # not clear if this is supposed to be True or False, # but it used to give a SystemError + @support.cpython_only + def test_bug_31608(self): + # The interpreter used to crash in specific cases where a deque + # subclass returned a non-deque. + class X(deque): + pass + d = X() + def bad___new__(cls, *args, **kwargs): + return [42] + X.__new__ = bad___new__ + with self.assertRaises(TypeError): + d * 42 # shouldn't crash + with self.assertRaises(TypeError): + d + deque([1, 2, 3]) # shouldn't crash + class SubclassWithKwargs(deque): def __init__(self, newarg=1): |