summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2000-06-18 18:43:14 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2000-06-18 18:43:14 (GMT)
commit74042d6e5d44cc9d332c28414a1e04eadd204248 (patch)
tree888efb4a5da65b5fed5d282d019af6fb29fefe0b /Objects/abstract.c
parentb75c485f0bc6394f616d4a0bc746e613fd7b1021 (diff)
downloadcpython-74042d6e5d44cc9d332c28414a1e04eadd204248.zip
cpython-74042d6e5d44cc9d332c28414a1e04eadd204248.tar.gz
cpython-74042d6e5d44cc9d332c28414a1e04eadd204248.tar.bz2
Patch from /F:
this patch introduces PySequence_Fast and PySequence_Fast_GET_ITEM, and modifies the list.extend method to accept any kind of sequence.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 410b80b..79af2f8 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1207,6 +1207,26 @@ PySequence_List(v)
return type_error("list() argument must be a sequence");
}
+PyObject *
+PySequence_Fast(v, m)
+ PyObject *v;
+ const char* m;
+{
+ if (v == NULL)
+ return null_error();
+
+ if (PyList_Check(v) || PyTuple_Check(v)) {
+ Py_INCREF(v);
+ return v;
+ }
+
+ v = PySequence_Tuple(v);
+ if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError))
+ return type_error(m);
+
+ return v;
+}
+
int
PySequence_Count(s, o)
PyObject *s;