Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a53f2c9

Browse files
committed
Merged revisions 77823 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ................ r77823 | mark.dickinson | 2010-01-29 17:27:24 +0000 (Fri, 29 Jan 2010) | 10 lines Merged revisions 77821 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r77821 | mark.dickinson | 2010-01-29 17:11:39 +0000 (Fri, 29 Jan 2010) | 3 lines Issue #7788: Fix a crash produced by deleting a list slice with huge step value. Patch by Marcin Bachry. ........ ................
1 parent d692c4a commit a53f2c9

7 files changed

Lines changed: 17 additions & 5 deletions

File tree

Lib/test/list_tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ def test_extendedslicing(self):
540540
a = self.type2test(range(10))
541541
a[::2] = tuple(range(5))
542542
self.assertEqual(a, self.type2test([0, 1, 1, 3, 2, 5, 3, 7, 4, 9]))
543+
# test issue7788
544+
a = self.type2test(range(10))
545+
del a[9::1<<333]
543546

544547
def test_constructor_exception_handling(self):
545548
# Bug #1242657

Lib/test/test_array.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ def test_delslice(self):
848848
a = array.array(self.typecode, range(10))
849849
del a[::1000]
850850
self.assertEqual(a, array.array(self.typecode, [1,2,3,4,5,6,7,8,9]))
851+
# test issue7788
852+
a = array.array(self.typecode, range(10))
853+
del a[9::1<<333]
851854

852855
def test_assignment(self):
853856
a = array.array(self.typecode, range(10))

Lib/test/test_bytes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def test_setslice(self):
595595
self.assertEqual(b, bytearray([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9]))
596596

597597
def test_extended_set_del_slice(self):
598-
indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300)
598+
indices = (0, None, 1, 3, 19, 300, 1<<333, -1, -2, -31, -300)
599599
for start in indices:
600600
for stop in indices:
601601
# Skip invalid step 0

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.1.2?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #7788: Fix an interpreter crash produced by deleting a list
16+
slice with very large step value.
17+
1518
- Issue #7561: Operations on empty bytearrays (such as `int(bytearray())`)
1619
could crash in many places because of the PyByteArray_AS_STRING() macro
1720
returning NULL. The macro now returns a statically allocated empty

Modules/arraymodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,8 +1733,9 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
17331733
}
17341734
else if (needed == 0) {
17351735
/* Delete slice */
1736-
Py_ssize_t cur, i;
1737-
1736+
size_t cur;
1737+
Py_ssize_t i;
1738+
17381739
if (step < 0) {
17391740
stop = start + 1;
17401741
start = stop + step * (slicelength - 1) - 1;

Objects/bytearrayobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,8 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
650650
else {
651651
if (needed == 0) {
652652
/* Delete slice */
653-
Py_ssize_t cur, i;
653+
size_t cur;
654+
Py_ssize_t i;
654655

655656
if (!_canresize(self))
656657
return -1;

Objects/listobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2430,7 +2430,8 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
24302430
if (value == NULL) {
24312431
/* delete slice */
24322432
PyObject **garbage;
2433-
Py_ssize_t cur, i;
2433+
size_t cur;
2434+
Py_ssize_t i;
24342435

24352436
if (slicelength <= 0)
24362437
return 0;

0 commit comments

Comments
 (0)