mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
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.
This commit is contained in:
parent
a0e454b69d
commit
c0f59ad145
3 changed files with 19 additions and 15 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue