Message7049
Here is a patch that I believe fixes the problem (by deleting one equals sign). The patch also adds a new test case to Lib/test/test_list_jy.py, with two methods modelled on the CPython test for slice assignment and deletion. The CPython test was insufficient to detect our mistake in Jython.
The problem was with deletion, but I've written a corresponding test for assignment too as it was similar.
I've written the tests with the intention they migrate eventually to the CPython code base (in list_tests.py, to supplement CommonTest.test_extendedslicing() ). This worked in a quick test with Python 2.7.2.
With the new test in place, but before the fix to SequenceIndexDelegate, Jython 2.7+ fails the test like this:
>dist\bin\jython Lib\test\test_list_jy.py
test_recursive_list_slices (__main__.ListTestCase) ... ok
test_setget_override (__main__.ListTestCase) ... ok
test_subclass_richcmp (__main__.ListTestCase) ... ok
test_tuple_equality (__main__.ListTestCase) ... ok
test_append_remove (__main__.ThreadSafetyTestCase) ... ok
test_count_reverse (__main__.ThreadSafetyTestCase) ... ok
test_sort (__main__.ThreadSafetyTestCase) ... ok
test_extended_slice_assign (__main__.ExtendedSliceTestCase) ... ok
test_extended_slice_delete (__main__.ExtendedSliceTestCase) ... FAIL
======================================================================
FAIL: test_extended_slice_delete (__main__.ExtendedSliceTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib\test\test_list_jy.py", line 143, in test_extended_slice_delete
self.assertEqual(a, expected1)
AssertionError: Lists differ: [0, 1, 2, 3, 4, 10, 11, 12, 13... != [0, 1, 2, 3, 4, 5, 10, 11, 12,...
First differing element 5:
10
5
Second list contains 1 additional elements.
First extra element 9:
13
- [0, 1, 2, 3, 4, 10, 11, 12, 13]
+ [0, 1, 2, 3, 4, 5, 10, 11, 12, 13]
? +++
The offending call was essentially:
a = list(range(14))
del a[9:5:-1]
and element 5 was deleted, incorrectly. Python 2.7.2 passes the test. After the change, Jython passes like this:
>dist\bin\jython Lib\test\test_list_jy.py
test_recursive_list_slices (__main__.ListTestCase) ... ok
test_setget_override (__main__.ListTestCase) ... ok
test_subclass_richcmp (__main__.ListTestCase) ... ok
test_tuple_equality (__main__.ListTestCase) ... ok
test_append_remove (__main__.ThreadSafetyTestCase) ... ok
test_count_reverse (__main__.ThreadSafetyTestCase) ... ok
test_sort (__main__.ThreadSafetyTestCase) ... ok
test_extended_slice_assign (__main__.ExtendedSliceTestCase) ... ok
test_extended_slice_delete (__main__.ExtendedSliceTestCase) ... ok
----------------------------------------------------------------------
Ran 9 tests in 0.936s |
|
Date |
User |
Action |
Args |
2012-04-12 13:52:31 | jeff.allen | set | messageid: <1334238751.45.0.733599691544.issue1873@psf.upfronthosting.co.za> |
2012-04-12 13:52:31 | jeff.allen | set | recipients:
+ jeff.allen, fwierzbicki |
2012-04-12 13:52:31 | jeff.allen | link | issue1873 messages |
2012-04-12 13:52:31 | jeff.allen | create | |
|