diff Objects/methodobject.c @ 19198:3c1c9948ff65 legacy-trunk

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.)
author Jeremy Hylton <jeremy@alum.mit.edu>
date Sun, 12 Aug 2001 21:52:24 +0000
parents 09df3254b49d
children b9701538f827
line wrap: on
line diff
--- a/Objects/methodobject.c	Sun Aug 12 09:28:40 2001 +0000
+++ b/Objects/methodobject.c	Sun Aug 12 21:52:24 2001 +0000
@@ -56,6 +56,40 @@
 	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 @@
 	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 @@
 	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 */