Skip to content

Commit d9ab273

Browse files
committed
Revert last change, it was done that way for a reason
1 parent bf0d0fc commit d9ab273

File tree

1 file changed

+6
-46
lines changed

1 file changed

+6
-46
lines changed

src/arrays.sip

+6-46
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,8 @@
2323
// Code to test a PyObject for compatibility
2424
// Verify that the object is a sequence, but not bytes or unicode
2525
if (!sipIsErr) {
26-
if (PySequence_Check(sipPy) &&
27-
!(PyBytes_Check(sipPy) || PyUnicode_Check(sipPy))) {
28-
29-
Py_ssize_t i, len = PySequence_Length(sipPy);
30-
bool failed;
31-
for (i=0; i<len; i++) {
32-
PyObject* item = PySequence_GetItem(sipPy, i);
33-
failed = !PyBytes_Check(item) && !PyUnicode_Check(item);
34-
Py_DECREF(item);
35-
if (failed)
36-
return FALSE;
37-
}
38-
return TRUE;
39-
}
40-
return FALSE;
41-
26+
return (PySequence_Check(sipPy) &&
27+
!(PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)));
4228
}
4329

4430

@@ -123,21 +109,8 @@ wxArrayString testArrayStringTypemap(const wxArrayString& arr);
123109
%ConvertToTypeCode
124110
// Code to test a PyObject for compatibility
125111
if (!sipIsErr) {
126-
if (PySequence_Check(sipPy) &&
127-
!(PyBytes_Check(sipPy) || PyUnicode_Check(sipPy))) {
128-
129-
Py_ssize_t i, len = PySequence_Length(sipPy);
130-
bool failed;
131-
for (i=0; i<len; i++) {
132-
PyObject* item = PySequence_GetItem(sipPy, i);
133-
failed = !PyNumber_Check(item);
134-
Py_DECREF(item);
135-
if (failed)
136-
return FALSE;
137-
}
138-
return TRUE;
139-
}
140-
return FALSE;
112+
return (PySequence_Check(sipPy) &&
113+
!(PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)));
141114
}
142115

143116
// Code to create a new wxArrayInt and convert a compatible PyObject
@@ -209,21 +182,8 @@ wxArrayInt testArrayIntTypemap(const wxArrayInt& arr);
209182
%ConvertToTypeCode
210183
// Code to test a PyObject for compatibility
211184
if (!sipIsErr) {
212-
if (PySequence_Check(sipPy) &&
213-
!(PyBytes_Check(sipPy) || PyUnicode_Check(sipPy))) {
214-
215-
Py_ssize_t i, len = PySequence_Length(sipPy);
216-
bool failed;
217-
for (i=0; i<len; i++) {
218-
PyObject* item = PySequence_GetItem(sipPy, i);
219-
failed = !PyNumber_Check(item);
220-
Py_DECREF(item);
221-
if (failed)
222-
return FALSE;
223-
}
224-
return TRUE;
225-
}
226-
return FALSE;
185+
return (PySequence_Check(sipPy) &&
186+
!(PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)));
227187
}
228188

229189
// Code to create a new wxArrayDouble and convert a compatible PyObject

0 commit comments

Comments
 (0)