Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,19 @@ def test_boundary_error_message_with_negative_offset(self):
'offset -11 out of range for 10-byte buffer'):
struct.pack_into('<B', byte_list, -11, 123)

def test_bad_value_error_message(self):
regex = (
r'got bad value at item 4, short format requires '
)
with self.assertRaisesRegex(struct.error, regex):
struct.pack('4h', 0x5FFF, 0x6FFF, 0x7FFF, 0x8FFF)
with self.assertRaisesRegex(struct.error, regex):
struct.pack('3hh', 0x5FFF, 0x6FFF, 0x7FFF, 0x8FFF)
with self.assertRaisesRegex(struct.error, regex):
struct.pack('hhhh', 0x5FFF, 0x6FFF, 0x7FFF, 0x8FFF)
with self.assertRaisesRegex(struct.error, regex):
struct.pack('iihh', 0x5FFF, 0x6FFF, 0x7FFF, 0x8FFF)

def test_issue29802(self):
# When the second argument of struct.unpack() was of wrong type
# the Struct object was decrefed twice and the reference to
Expand Down
Loading