diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-02-02 13:24:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-02-02 13:24:16 (GMT) |
commit | c0f59ad1455a53b6a8a9f09620ae4283e4df9f26 (patch) | |
tree | 2777c138d7b040194dba9a44926a325755a601dd /Lib/test/test_struct.py | |
parent | a0e454b69d4e00c75eb04ffe7268b65dc51ae54b (diff) | |
download | cpython-c0f59ad1455a53b6a8a9f09620ae4283e4df9f26.zip cpython-c0f59ad1455a53b6a8a9f09620ae4283e4df9f26.tar.gz cpython-c0f59ad1455a53b6a8a9f09620ae4283e4df9f26.tar.bz2 |
Rename struct.unpack() 2nd parameter to "buffer"
Issue #29300: Rename struct.unpack() second parameter from "inputstr" to
"buffer", and use the Py_buffer type.
Fix also unit tests on struct.unpack() which passed a Unicode string instead of
a bytes string as struct.unpack() second parameter. The purpose of
test_trailing_counter() is to test invalid format strings, not to test the
buffer parameter.
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r-- | Lib/test/test_struct.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index be00475..cf1d567 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -530,13 +530,13 @@ class StructTest(unittest.TestCase): # format lists containing only count spec should result in an error self.assertRaises(struct.error, struct.pack, '12345') - self.assertRaises(struct.error, struct.unpack, '12345', '') + self.assertRaises(struct.error, struct.unpack, '12345', b'') self.assertRaises(struct.error, struct.pack_into, '12345', store, 0) self.assertRaises(struct.error, struct.unpack_from, '12345', store, 0) # Format lists with trailing count spec should result in an error self.assertRaises(struct.error, struct.pack, 'c12345', 'x') - self.assertRaises(struct.error, struct.unpack, 'c12345', 'x') + self.assertRaises(struct.error, struct.unpack, 'c12345', b'x') self.assertRaises(struct.error, struct.pack_into, 'c12345', store, 0, 'x') self.assertRaises(struct.error, struct.unpack_from, 'c12345', store, @@ -545,7 +545,7 @@ class StructTest(unittest.TestCase): # Mixed format tests self.assertRaises(struct.error, struct.pack, '14s42', 'spam and eggs') self.assertRaises(struct.error, struct.unpack, '14s42', - 'spam and eggs') + b'spam and eggs') self.assertRaises(struct.error, struct.pack_into, '14s42', store, 0, 'spam and eggs') self.assertRaises(struct.error, struct.unpack_from, '14s42', store, 0) |