diff options
author | Oren Milman <orenmn@gmail.com> | 2018-09-11 18:46:55 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-09-11 18:46:55 (GMT) |
commit | 24bd50bdcc97d65130c07d6cd26085fd06c3e972 (patch) | |
tree | 910e8fbb4e6df9a32a19caaef1338c78a1f37d7a /Lib | |
parent | b4ec36200a959da70eba94c19826446a8efdffdd (diff) | |
download | cpython-24bd50bdcc97d65130c07d6cd26085fd06c3e972.zip cpython-24bd50bdcc97d65130c07d6cd26085fd06c3e972.tar.gz cpython-24bd50bdcc97d65130c07d6cd26085fd06c3e972.tar.bz2 |
closes bpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-3788)
Diffstat (limited to 'Lib')
-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 e895c3c..9211360 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -892,6 +892,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): |