Skip to content

Commit

Permalink
One more assertion against n=0 writes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpshead committed Feb 12, 2024
1 parent 4859a9b commit 97292ba
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Lib/test/test_capi/test_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,13 @@ def test_long_asnativebytes(self):
buffer = bytearray(b"\x5a")
self.assertEqual(expect, asnativebytes(v, buffer, 0, -1),
"PyLong_AsNativeBytes(v, <unknown>, 0, -1)")
self.assertEqual(buffer, b"\x5a",
"buffer overwritten when it should not have been")
# Also check via the __index__ path
self.assertEqual(expect, asnativebytes(Index(v), buffer, 0, -1),
"PyLong_AsNativeBytes(Index(v), <unknown>, 0, -1)")
self.assertEqual(buffer, b"\x5a",
"buffer overwritten when it should not have been")

# Test that we populate n=2 bytes but do not overwrite more.
buffer = bytearray(b"\x99"*3)
Expand Down

0 comments on commit 97292ba

Please sign in to comment.