diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 02d50b2d1c3..b2a5f429e0b 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -599,6 +599,16 @@ class StructTest(unittest.TestCase): 'offset -11 out of range for 10-byte buffer'): struct.pack_into('s_size) { + assert(offset >= 0); + assert(soself->s_size >= 0); + PyErr_Format(StructError, - "pack_into requires a buffer of at least %zd bytes for " + "pack_into requires a buffer of at least %zu bytes for " "packing %zd bytes at offset %zd " "(actual buffer size is %zd)", - soself->s_size + offset, + (size_t)soself->s_size + (size_t)offset, soself->s_size, offset, buffer.len);