diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-02 07:26:14 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-02 07:26:14 (GMT) |
commit | 0b2cacb42a7a3a79c1d5c491c584f57aa5c82417 (patch) | |
tree | 146cccf1d3df541b76a239ff85fb960f1389105d /Lib/test/test_bytes.py | |
parent | 5d64858ac8a226760785246bbc1c836b9fcb7f77 (diff) | |
parent | 83cf99d733acb49c70dd9548eeccfc724e707531 (diff) | |
download | cpython-0b2cacb42a7a3a79c1d5c491c584f57aa5c82417.zip cpython-0b2cacb42a7a3a79c1d5c491c584f57aa5c82417.tar.gz cpython-0b2cacb42a7a3a79c1d5c491c584f57aa5c82417.tar.bz2 |
Issue #20335: bytes constructor now raises TypeError when encoding or errors
is specified with non-string argument. Based on patch by Renaud Blanch.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 1e11437..ef4af9c 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -100,6 +100,14 @@ class BaseBytesTest: self.assertRaises(TypeError, self.type2test, [0.0]) self.assertRaises(TypeError, self.type2test, [None]) self.assertRaises(TypeError, self.type2test, [C()]) + self.assertRaises(TypeError, self.type2test, 0, 'ascii') + self.assertRaises(TypeError, self.type2test, b'', 'ascii') + self.assertRaises(TypeError, self.type2test, 0, errors='ignore') + self.assertRaises(TypeError, self.type2test, b'', errors='ignore') + self.assertRaises(TypeError, self.type2test, '') + self.assertRaises(TypeError, self.type2test, '', errors='ignore') + self.assertRaises(TypeError, self.type2test, '', b'ascii') + self.assertRaises(TypeError, self.type2test, '', 'ascii', b'ignore') def test_constructor_value_errors(self): self.assertRaises(ValueError, self.type2test, [-1]) |