summaryrefslogtreecommitdiff
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-02-10 14:19:36 +0100
committerVictor Stinner <victor.stinner@gmail.com>2017-02-10 14:19:36 +0100
commitec7729dfc2425044ab4d508165b4fb0a00c065d0 (patch)
tree1c6ce12497bf9bd8b32ee6a4af26ddafdc40da61 /Python/modsupport.c
parentd3f4d3fd74ca4924bbca57433ba13435c164978e (diff)
downloadcpython-ec7729dfc2425044ab4d508165b4fb0a00c065d0.tar.gz
Backed out changeset f23fa1f7b68fHEADmaster
Sorry, I didn't want to push this change before the review :-( I was pushing a change into the 2.7 branch.
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 9637191feb..e9e025bdb2 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -586,6 +586,57 @@ va_build_stack(PyObject **small_stack, Py_ssize_t small_stack_len,
}
+PyObject *
+PyEval_CallFunction(PyObject *callable, const char *format, ...)
+{
+ va_list vargs;
+ PyObject *args;
+ PyObject *res;
+
+ va_start(vargs, format);
+
+ args = Py_VaBuildValue(format, vargs);
+ va_end(vargs);
+
+ if (args == NULL)
+ return NULL;
+
+ res = PyEval_CallObject(callable, args);
+ Py_DECREF(args);
+
+ return res;
+}
+
+
+PyObject *
+PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...)
+{
+ va_list vargs;
+ PyObject *meth;
+ PyObject *args;
+ PyObject *res;
+
+ meth = PyObject_GetAttrString(obj, name);
+ if (meth == NULL)
+ return NULL;
+
+ va_start(vargs, format);
+
+ args = Py_VaBuildValue(format, vargs);
+ va_end(vargs);
+
+ if (args == NULL) {
+ Py_DECREF(meth);
+ return NULL;
+ }
+
+ res = PyEval_CallObject(meth, args);
+ Py_DECREF(meth);
+ Py_DECREF(args);
+
+ return res;
+}
+
int
PyModule_AddObject(PyObject *m, const char *name, PyObject *o)
{