diff options
author | Eli Bendersky <eliben@gmail.com> | 2011-07-29 04:05:08 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2011-07-29 04:05:08 (GMT) |
commit | 906b88fb2a52725e78deeb8076a52671107e2af1 (patch) | |
tree | b3a9397d8e65a13d275731f7447088389c0a3526 /Lib/test/test_getargs2.py | |
parent | 66d2be898611f32e3840025055f2cd9b92b9f19c (diff) | |
download | cpython-906b88fb2a52725e78deeb8076a52671107e2af1.zip cpython-906b88fb2a52725e78deeb8076a52671107e2af1.tar.gz cpython-906b88fb2a52725e78deeb8076a52671107e2af1.tar.bz2 |
Issue #12380: PyArg_ParseTuple now accepts a bytearray for the 'c' format.
As a side effect, this now allows the rjust, ljust and center methods of
bytes and bytearray to accept a bytearray argument.
Patch by Petri Lehtinen
Diffstat (limited to 'Lib/test/test_getargs2.py')
-rw-r--r-- | Lib/test/test_getargs2.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 3d9c06a..768ea8d 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -294,6 +294,15 @@ class Keywords_TestCase(unittest.TestCase): self.fail('TypeError should have been raised') class Bytes_TestCase(unittest.TestCase): + def test_c(self): + from _testcapi import getargs_c + self.assertRaises(TypeError, getargs_c, b'abc') # len > 1 + self.assertEqual(getargs_c(b'a'), b'a') + self.assertEqual(getargs_c(bytearray(b'a')), b'a') + self.assertRaises(TypeError, getargs_c, memoryview(b'a')) + self.assertRaises(TypeError, getargs_c, 's') + self.assertRaises(TypeError, getargs_c, None) + def test_s(self): from _testcapi import getargs_s self.assertEqual(getargs_s('abc\xe9'), b'abc\xc3\xa9') |