| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -252,9 +252,9 @@ typedef struct { | |||
| 252 | 252 | binaryfunc sq_concat; | |
| 253 | 253 | ssizeargfunc sq_repeat; | |
| 254 | 254 | ssizeargfunc sq_item; | |
| 255 | - ssizessizeargfunc sq_slice; | ||
| 255 | + void *was_sq_slice; | ||
| 256 | 256 | ssizeobjargproc sq_ass_item; | |
| 257 | - ssizessizeobjargproc sq_ass_slice; | ||
| 257 | + void *was_sq_ass_slice; | ||
| 258 | 258 | objobjproc sq_contains; | |
| 259 | 259 | ||
| 260 | 260 | binaryfunc sq_inplace_concat; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,15 +36,6 @@ extern "C" { | |||
| 36 | 36 | #define INPLACE_FLOOR_DIVIDE 28 | |
| 37 | 37 | #define INPLACE_TRUE_DIVIDE 29 | |
| 38 | 38 | ||
| 39 | - #define SLICE 30 | ||
| 40 | - /* Also uses 31-33 */ | ||
| 41 | - | ||
| 42 | - #define STORE_SLICE 40 | ||
| 43 | - /* Also uses 41-43 */ | ||
| 44 | - | ||
| 45 | - #define DELETE_SLICE 50 | ||
| 46 | - /* Also uses 51-53 */ | ||
| 47 | - | ||
| 48 | 39 | #define INPLACE_ADD 55 | |
| 49 | 40 | #define INPLACE_SUBTRACT 56 | |
| 50 | 41 | #define INPLACE_MULTIPLY 57 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,20 +28,6 @@ def __len__(self): return len(self.data) | |||
| 28 | 28 | def __getitem__(self, i): return self.data[i] | |
| 29 | 29 | def __setitem__(self, i, item): self.data[i] = item | |
| 30 | 30 | def __delitem__(self, i): del self.data[i] | |
| 31 | - def __getslice__(self, i, j): | ||
| 32 | - i = max(i, 0); j = max(j, 0) | ||
| 33 | - return self.__class__(self.data[i:j]) | ||
| 34 | - def __setslice__(self, i, j, other): | ||
| 35 | - i = max(i, 0); j = max(j, 0) | ||
| 36 | - if isinstance(other, UserList): | ||
| 37 | - self.data[i:j] = other.data | ||
| 38 | - elif isinstance(other, type(self.data)): | ||
| 39 | - self.data[i:j] = other | ||
| 40 | - else: | ||
| 41 | - self.data[i:j] = list(other) | ||
| 42 | - def __delslice__(self, i, j): | ||
| 43 | - i = max(i, 0); j = max(j, 0) | ||
| 44 | - del self.data[i:j] | ||
| 45 | 31 | def __add__(self, other): | |
| 46 | 32 | if isinstance(other, UserList): | |
| 47 | 33 | return self.__class__(self.data + other.data) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,10 +63,6 @@ def __contains__(self, char): | |||
| 63 | 63 | ||
| 64 | 64 | def __len__(self): return len(self.data) | |
| 65 | 65 | def __getitem__(self, index): return self.__class__(self.data[index]) | |
| 66 | - def __getslice__(self, start, end): | ||
| 67 | - start = max(start, 0); end = max(end, 0) | ||
| 68 | - return self.__class__(self.data[start:end]) | ||
| 69 | - | ||
| 70 | 66 | def __add__(self, other): | |
| 71 | 67 | if isinstance(other, UserString): | |
| 72 | 68 | return self.__class__(self.data + other.data) | |
@@ -220,17 +216,6 @@ def __delitem__(self, index): | |||
| 220 | 216 | index += len(self.data) | |
| 221 | 217 | if index < 0 or index >= len(self.data): raise IndexError | |
| 222 | 218 | self.data = self.data[:index] + self.data[index+1:] | |
| 223 | - def __setslice__(self, start, end, sub): | ||
| 224 | - start = max(start, 0); end = max(end, 0) | ||
| 225 | - if isinstance(sub, UserString): | ||
| 226 | - self.data = self.data[:start]+sub.data+self.data[end:] | ||
| 227 | - elif isinstance(sub, basestring): | ||
| 228 | - self.data = self.data[:start]+sub+self.data[end:] | ||
| 229 | - else: | ||
| 230 | - self.data = self.data[:start]+str(sub)+self.data[end:] | ||
| 231 | - def __delslice__(self, start, end): | ||
| 232 | - start = max(start, 0); end = max(end, 0) | ||
| 233 | - self.data = self.data[:start] + self.data[end:] | ||
| 234 | 219 | def immutable(self): | |
| 235 | 220 | return UserString(self.data) | |
| 236 | 221 | def __iadd__(self, other): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,20 +70,6 @@ def jabs_op(name, op): | |||
| 70 | 70 | def_op('BINARY_TRUE_DIVIDE', 27) | |
| 71 | 71 | def_op('INPLACE_FLOOR_DIVIDE', 28) | |
| 72 | 72 | def_op('INPLACE_TRUE_DIVIDE', 29) | |
| 73 | - def_op('SLICE+0', 30) | ||
| 74 | - def_op('SLICE+1', 31) | ||
| 75 | - def_op('SLICE+2', 32) | ||
| 76 | - def_op('SLICE+3', 33) | ||
| 77 | - | ||
| 78 | - def_op('STORE_SLICE+0', 40) | ||
| 79 | - def_op('STORE_SLICE+1', 41) | ||
| 80 | - def_op('STORE_SLICE+2', 42) | ||
| 81 | - def_op('STORE_SLICE+3', 43) | ||
| 82 | - | ||
| 83 | - def_op('DELETE_SLICE+0', 50) | ||
| 84 | - def_op('DELETE_SLICE+1', 51) | ||
| 85 | - def_op('DELETE_SLICE+2', 52) | ||
| 86 | - def_op('DELETE_SLICE+3', 53) | ||
| 87 | 73 | ||
| 88 | 74 | def_op('INPLACE_ADD', 55) | |
| 89 | 75 | def_op('INPLACE_SUBTRACT', 56) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,8 +139,6 @@ def __getitem__(self, index): | |||
| 139 | 139 | return self.data[index] | |
| 140 | 140 | def __setitem__(self, index, code): | |
| 141 | 141 | self.data[index] = code | |
| 142 | - def __getslice__(self, start, stop): | ||
| 143 | - return SubPattern(self.pattern, self.data[start:stop]) | ||
| 144 | 142 | def insert(self, index, code): | |
| 145 | 143 | self.data.insert(index, code) | |
| 146 | 144 | def append(self, code): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,10 +178,8 @@ def test_setslice(self): | |||
| 178 | 178 | a[:] = tuple(range(10)) | |
| 179 | 179 | self.assertEqual(a, self.type2test(range(10))) | |
| 180 | 180 | ||
| 181 | - self.assertRaises(TypeError, a.__setslice__, 0, 1, 5) | ||
| 182 | 181 | self.assertRaises(TypeError, a.__setitem__, slice(0, 1, 5)) | |
| 183 | 182 | ||
| 184 | - self.assertRaises(TypeError, a.__setslice__) | ||
| 185 | 183 | self.assertRaises(TypeError, a.__setitem__) | |
| 186 | 184 | ||
| 187 | 185 | def test_delslice(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,8 +196,6 @@ def test_getslice(self): | |||
| 196 | 196 | self.assertEqual(a[ -pow(2,128): 3 ], self.type2test([0,1,2])) | |
| 197 | 197 | self.assertEqual(a[ 3: pow(2,145) ], self.type2test([3,4])) | |
| 198 | 198 | ||
| 199 | - self.assertRaises(TypeError, u.__getslice__) | ||
| 200 | - | ||
| 201 | 199 | def test_contains(self): | |
| 202 | 200 | u = self.type2test([0, 1, 2]) | |
| 203 | 201 | for i in u: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -939,17 +939,17 @@ def test_subscript(self): | |||
| 939 | 939 | self.checkraises(TypeError, 'abc', '__getitem__', 'def') | |
| 940 | 940 | ||
| 941 | 941 | def test_slice(self): | |
| 942 | - self.checkequal('abc', 'abc', '__getslice__', 0, 1000) | ||
| 943 | - self.checkequal('abc', 'abc', '__getslice__', 0, 3) | ||
| 944 | - self.checkequal('ab', 'abc', '__getslice__', 0, 2) | ||
| 945 | - self.checkequal('bc', 'abc', '__getslice__', 1, 3) | ||
| 946 | - self.checkequal('b', 'abc', '__getslice__', 1, 2) | ||
| 947 | - self.checkequal('', 'abc', '__getslice__', 2, 2) | ||
| 948 | - self.checkequal('', 'abc', '__getslice__', 1000, 1000) | ||
| 949 | - self.checkequal('', 'abc', '__getslice__', 2000, 1000) | ||
| 950 | - self.checkequal('', 'abc', '__getslice__', 2, 1) | ||
| 951 | - | ||
| 952 | - self.checkraises(TypeError, 'abc', '__getslice__', 'def') | ||
| 942 | + self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000)) | ||
| 943 | + self.checkequal('abc', 'abc', '__getitem__', slice(0, 3)) | ||
| 944 | + self.checkequal('ab', 'abc', '__getitem__', slice(0, 2)) | ||
| 945 | + self.checkequal('bc', 'abc', '__getitem__', slice(1, 3)) | ||
| 946 | + self.checkequal('b', 'abc', '__getitem__', slice(1, 2)) | ||
| 947 | + self.checkequal('', 'abc', '__getitem__', slice(2, 2)) | ||
| 948 | + self.checkequal('', 'abc', '__getitem__', slice(1000, 1000)) | ||
| 949 | + self.checkequal('', 'abc', '__getitem__', slice(2000, 1000)) | ||
| 950 | + self.checkequal('', 'abc', '__getitem__', slice(2, 1)) | ||
| 951 | + | ||
| 952 | + self.checkraises(TypeError, 'abc', '__getitem__', 'def') | ||
| 953 | 953 | ||
| 954 | 954 | def test_extended_getslice(self): | |
| 955 | 955 | # Test extended slicing by comparing with list slicing. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -562,12 +562,10 @@ def test_setslice(self): | |||
| 562 | 562 | ) | |
| 563 | 563 | ||
| 564 | 564 | a = array.array(self.typecode, self.example) | |
| 565 | - self.assertRaises(TypeError, a.__setslice__, 0, 0, None) | ||
| 566 | 565 | self.assertRaises(TypeError, a.__setitem__, slice(0, 0), None) | |
| 567 | 566 | self.assertRaises(TypeError, a.__setitem__, slice(0, 1), None) | |
| 568 | 567 | ||
| 569 | 568 | b = array.array(self.badtypecode()) | |
| 570 | - self.assertRaises(TypeError, a.__setslice__, 0, 0, b) | ||
| 571 | 569 | self.assertRaises(TypeError, a.__setitem__, slice(0, 0), b) | |
| 572 | 570 | self.assertRaises(TypeError, a.__setitem__, slice(0, 1), b) | |
| 573 | 571 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments