summaryrefslogtreecommitdiff
path: root/Modules/stropmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/stropmodule.c')
-rw-r--r--Modules/stropmodule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 73c2d85683..2d11851e7c 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -274,13 +274,15 @@ strop_joinfields(self, args)
}
return res;
}
- else if (!PySequence_Check(seq)) {
+
+ if (seq->ob_type->tp_as_sequence == NULL ||
+ (getitemfunc = seq->ob_type->tp_as_sequence->sq_item) == NULL)
+ {
PyErr_SetString(PyExc_TypeError,
"first argument must be a sequence");
return NULL;
}
- /* type safe */
- getitemfunc = seq->ob_type->tp_as_sequence->sq_item;
+ /* This is now type safe */
for (i = 0; i < seqlen; i++) {
PyObject *item = getitemfunc(seq, i);
if (!item || !PyString_Check(item)) {