Skip to content

Commit 9681135

Browse files
committed
Add +1 so allocation is over max byte length
On 32 bit systems with 4GB of ram there may be PY_SSIZE_T_MAX allocatable and the testt would pass as the allocation would succeed. Add a + 1 so that it's over the max bytes length and an OverflowError will be raised by bytes.
1 parent c470178 commit 9681135

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/test/test_capi/test_bytearray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def test_fromstringandsize(self):
5757
self.assertEqual(fromstringandsize(NULL, 0), bytearray())
5858
self.assertEqual(len(fromstringandsize(NULL, 3)), 3)
5959
self.assertRaises(OverflowError, fromstringandsize, NULL, PY_SSIZE_T_MAX)
60-
self.assertRaises(MemoryError, fromstringandsize, NULL,
61-
PY_SSIZE_T_MAX-sys.getsizeof(b''))
60+
self.assertRaises(OverflowError, fromstringandsize, NULL,
61+
PY_SSIZE_T_MAX-sys.getsizeof(b'') + 1)
6262

6363
self.assertRaises(SystemError, fromstringandsize, b'abc', -1)
6464
self.assertRaises(SystemError, fromstringandsize, b'abc', PY_SSIZE_T_MIN)

0 commit comments

Comments
 (0)