Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix issue 30245
  • Loading branch information
johanliu committed May 20, 2017
commit f228dd772cff9f0b526474f860d180899b660984
10 changes: 10 additions & 0 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ def test_pack_into(self):
self.assertRaises((TypeError, struct.error), struct.pack_into, b'', sb,
None)

# Test overflows cause by large offset and value size (issue 30245)
regex = (
r'pack_into requires a buffer of at least 9223372036854775811 '
r'bytes for packing 4 bytes at offset 9223372036854775807 '
r'\(actual buffer size is 10\)'
)

with self.assertRaisesRegex(struct.error, regex):
struct.pack_into('I', bytearray(10), sys.maxsize, 1)

def test_pack_into_fn(self):
test_string = b'Reykjavik rocks, eow!'
writable_buf = array.array('b', b' '*100)
Expand Down