Skip to content

Commit 126652c

Browse files
committed
these don't exist on python < 3.6
1 parent ca2b58f commit 126652c

File tree

1 file changed

+36
-34
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests/cpyext

1 file changed

+36
-34
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_slice.py

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,18 @@ def reference_unpack(slize):
9090
raise ValueError("slice step cannot be zero")
9191
return (0, start, stop, step)
9292

93-
test_PySlice_Unpack = CPyExtFunction(
94-
lambda arg: TestPySlice.reference_unpack(*arg),
95-
lambda: (
96-
(slice(0,1,2),),
97-
(slice(0,-1),),
98-
(slice(None,-1,0),),
99-
(slice(0,1,-1),),
100-
(slice(1,-1),),
101-
(slice(1),),
102-
),
103-
code='''PyObject* wrapper_SliceUnpack(PyObject* slice) {
93+
if sys.version_info.minor >= 6:
94+
test_PySlice_Unpack = CPyExtFunction(
95+
lambda arg: TestPySlice.reference_unpack(*arg),
96+
lambda: (
97+
(slice(0,1,2),),
98+
(slice(0,-1),),
99+
(slice(None,-1,0),),
100+
(slice(0,1,-1),),
101+
(slice(1,-1),),
102+
(slice(1),),
103+
),
104+
code='''PyObject* wrapper_SliceUnpack(PyObject* slice) {
104105
Py_ssize_t start, stop, step;
105106
int result = PySlice_Unpack(slice, &start, &stop, &step);
106107
if (result < 0) {
@@ -109,12 +110,12 @@ def reference_unpack(slize):
109110
return Py_BuildValue("iiii", result, start, stop, step);
110111
}
111112
''',
112-
resultspec="O",
113-
argspec='O',
114-
callfunction="wrapper_SliceUnpack",
115-
arguments=["PyObject* slice"],
116-
cmpfunc=unhandled_error_compare
117-
)
113+
resultspec="O",
114+
argspec='O',
115+
callfunction="wrapper_SliceUnpack",
116+
arguments=["PyObject* slice"],
117+
cmpfunc=unhandled_error_compare
118+
)
118119

119120
def reference_adjust(length, start, stop, step):
120121
slicelength = -1
@@ -145,26 +146,27 @@ def reference_adjust(length, start, stop, step):
145146
return 0, start, stop
146147

147148

148-
test_PySlice_AdjustIndices = CPyExtFunction(
149-
lambda arg: TestPySlice.reference_adjust(*arg),
150-
lambda: (
151-
(3,0,-1,1),
152-
(3,1,-1,1),
153-
(12,-1,-1,-1),
154-
(12,-1,0,-1),
155-
(12,-1,0,-2),
156-
(3,1,-1,2),
157-
),
158-
code='''PyObject* Slice_AdjustIndices(int length, int sta, int sto, int step) {
149+
if sys.version_info.minor >= 6:
150+
test_PySlice_AdjustIndices = CPyExtFunction(
151+
lambda arg: TestPySlice.reference_adjust(*arg),
152+
lambda: (
153+
(3,0,-1,1),
154+
(3,1,-1,1),
155+
(12,-1,-1,-1),
156+
(12,-1,0,-1),
157+
(12,-1,0,-2),
158+
(3,1,-1,2),
159+
),
160+
code='''PyObject* Slice_AdjustIndices(int length, int sta, int sto, int step) {
159161
Py_ssize_t start = sta;
160162
Py_ssize_t stop = sto;
161163
int slicelength = PySlice_AdjustIndices(length, &start, &stop, step);
162164
return Py_BuildValue("iii", slicelength, start, stop);
163165
}
164166
''',
165-
resultspec="O",
166-
argspec='iiii',
167-
callfunction="Slice_AdjustIndices",
168-
arguments=["int length", "int start", "int stop", "int step"],
169-
cmpfunc=unhandled_error_compare
170-
)
167+
resultspec="O",
168+
argspec='iiii',
169+
callfunction="Slice_AdjustIndices",
170+
arguments=["int length", "int start", "int stop", "int step"],
171+
cmpfunc=unhandled_error_compare
172+
)

0 commit comments

Comments
 (0)