summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-08-12 21:52:24 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-08-12 21:52:24 (GMT)
commit910d7d46dce571fa81428718e9be5307a56adeee (patch)
tree0472ada0f5df1fcfff28efb22e2011dec2834e37 /Objects/methodobject.c
parentf65b1a175f0c9ddb662c1ee7fd4b45d8824c900c (diff)
downloadcpython-910d7d46dce571fa81428718e9be5307a56adeee.zip
cpython-910d7d46dce571fa81428718e9be5307a56adeee.tar.gz
cpython-910d7d46dce571fa81428718e9be5307a56adeee.tar.bz2
Remove much dead code from ceval.c
The descr changes moved the dispatch for calling objects from call_object() in ceval.c to PyObject_Call() in abstract.c. call_object() and the many functions it used in ceval.c were no longer used, but were not removed. Rename meth_call() as PyCFunction_Call() so that it can be called by the CALL_FUNCTION opcode in ceval.c. Also, fix error message that referred to PyEval_EvalCodeEx() by its old name eval_code2(). (I'll probably refer to it by its old name, too.)
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 56fbcc2..9d43044 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -56,6 +56,40 @@ PyCFunction_GetFlags(PyObject *op)
return ((PyCFunctionObject *)op) -> m_ml -> ml_flags;
}
+PyObject *
+PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
+{
+ PyCFunctionObject* f = (PyCFunctionObject*)func;
+ PyCFunction meth = PyCFunction_GET_FUNCTION(func);
+ PyObject *self = PyCFunction_GET_SELF(func);
+ int flags = PyCFunction_GET_FLAGS(func);
+
+ if (flags & METH_KEYWORDS) {
+ return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
+ }
+ if (kw != NULL && PyDict_Size(kw) != 0) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes no keyword arguments",
+ f->m_ml->ml_name);
+ return NULL;
+ }
+ if (flags & METH_VARARGS) {
+ return (*meth)(self, arg);
+ }
+ if (!(flags & METH_VARARGS)) {
+ /* the really old style */
+ int size = PyTuple_GET_SIZE(arg);
+ if (size == 1)
+ arg = PyTuple_GET_ITEM(arg, 0);
+ else if (size == 0)
+ arg = NULL;
+ return (*meth)(self, arg);
+ }
+ /* should never get here ??? */
+ PyErr_BadInternalCall();
+ return NULL;
+}
+
/* Methods (the standard built-in methods, that is) */
static void
@@ -163,40 +197,6 @@ meth_hash(PyCFunctionObject *a)
return x;
}
-static PyObject *
-meth_call(PyObject *func, PyObject *arg, PyObject *kw)
-{
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
-
- if (flags & METH_KEYWORDS) {
- return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
- }
- if (kw != NULL && PyDict_Size(kw) != 0) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
- }
- if (flags & METH_VARARGS) {
- return (*meth)(self, arg);
- }
- if (!(flags & METH_VARARGS)) {
- /* the really old style */
- int size = PyTuple_GET_SIZE(arg);
- if (size == 1)
- arg = PyTuple_GET_ITEM(arg, 0);
- else if (size == 0)
- arg = NULL;
- return (*meth)(self, arg);
- }
- /* should never get here ??? */
- PyErr_BadInternalCall();
- return NULL;
-}
-
PyTypeObject PyCFunction_Type = {
PyObject_HEAD_INIT(&PyType_Type)
@@ -214,7 +214,7 @@ PyTypeObject PyCFunction_Type = {
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)meth_hash, /* tp_hash */
- meth_call, /* tp_call */
+ PyCFunction_Call, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */