PyArg_VaParse().
Closes patch #550732. Thanks Greg Chapman.
\begin{cfuncdesc}{PyObject*}{PyImport_AddModule}{char *name}
Return the module object corresponding to a module name. The
- \var{name} argument may be of the form \code{package.module}).
+ \var{name} argument may be of the form \code{package.module}.
First check the modules dictionary if there's one there, and if not,
create a new one and insert it in the modules dictionary.
Return \NULL{} with an exception set on failure.
failure, it returns false and raises the appropriate exception.
\end{cfuncdesc}
+\begin{cfuncdesc}{int}{PyArg_VaParse}{PyObject *args, char *format,
+ va_list vargs}
+ Identical to \cfunction{PyArg_ParseTuple()}, except that it accepts a
+ va_list rather than a variable number of arguments.
+\end{cfuncdesc}
+
\begin{cfuncdesc}{int}{PyArg_ParseTupleAndKeywords}{PyObject *args,
PyObject *kw, char *format, char *keywords[],
\moreargs}
on failure, it returns false and raises the appropriate exception.
\end{cfuncdesc}
+\begin{cfuncdesc}{int}{PyArg_VaParseTupleAndKeywords}{PyObject *args,
+ PyObject *kw, char *format, char *keywords[],
+ va_list vargs}
+ Identical to \cfunction{PyArg_ParseTupleAndKeywords()}, except that it
+ accepts a va_list rather than a variable number of arguments.
+\end{cfuncdesc}
+
\begin{cfuncdesc}{int}{PyArg_Parse}{PyObject *args, char *format,
\moreargs}
Function used to deconstruct the argument lists of ``old-style''
PyAPI_FUNC(PyObject *) Py_BuildValue(char *, ...);
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, char *, va_list);
+PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
+ char *, char **, va_list);
PyAPI_FUNC(PyObject *) Py_VaBuildValue(char *, va_list);
PyAPI_FUNC(int) PyModule_AddObject(PyObject *, char *, PyObject *);
Core and builtins
-----------------
+- Patch #550732: Add PyArg_VaParseTupleAndKeywords(). Analogous to
+PyArg_VaParse(). Both are now documented. Thanks Greg Chapman.
+
- Allow string and unicode return types from .encode()/.decode()
methods on string and unicode objects. Added unicode.decode()
which was missing for no apparent reason.
int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
char *, char **, ...);
+int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
+ char *, char **, va_list);
+
/* Forward */
static int vgetargs1(PyObject *, char *, va_list *, int);
}
+int
+PyArg_VaParseTupleAndKeywords(PyObject *args,
+ PyObject *keywords,
+ char *format,
+ char **kwlist, va_list va)
+{
+ int retval;
+ va_list lva;
+
+ if ((args == NULL || !PyTuple_Check(args)) ||
+ (keywords != NULL && !PyDict_Check(keywords)) ||
+ format == NULL ||
+ kwlist == NULL)
+ {
+ PyErr_BadInternalCall();
+ return 0;
+ }
+
+#ifdef VA_LIST_IS_ARRAY
+ memcpy(lva, va, sizeof(va_list));
+#else
+#ifdef __va_copy
+ __va_copy(lva, va);
+#else
+ lva = va;
+#endif
+#endif
+
+ retval = vgetargskeywords(args, keywords, format, kwlist, &lva);
+ return retval;
+}
+
+
static int
vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
char **kwlist, va_list *p_va)