diff options
author | Batuhan Taskaya <batuhan@python.org> | 2021-07-16 15:43:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-16 15:43:02 (GMT) |
commit | 9af34c935185eca497617a216d141c72ffaeae9c (patch) | |
tree | 06c965d71e81caaec5193a5220709136b2f5e8d3 /Include/modsupport.h | |
parent | 7915c96ffd7ddc5cb6d54015ee4c31255a416892 (diff) | |
download | cpython-9af34c935185eca497617a216d141c72ffaeae9c.zip cpython-9af34c935185eca497617a216d141c72ffaeae9c.tar.gz cpython-9af34c935185eca497617a216d141c72ffaeae9c.tar.bz2 |
bpo-20201: variadic arguments support for AC (GH-18609)
Implement support for `*args` in AC, and port `print()` to use it.
Diffstat (limited to 'Include/modsupport.h')
-rw-r--r-- | Include/modsupport.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Include/modsupport.h b/Include/modsupport.h index f009d58..7d37b49 100644 --- a/Include/modsupport.h +++ b/Include/modsupport.h @@ -50,6 +50,7 @@ PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); +#define ANY_VARARGS(n) (n == PY_SSIZE_T_MAX) #ifndef Py_LIMITED_API PyAPI_FUNC(int) _PyArg_UnpackStack( PyObject *const *args, @@ -73,7 +74,7 @@ PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, Py PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t); #define _PyArg_CheckPositional(funcname, nargs, min, max) \ - (((min) <= (nargs) && (nargs) <= (max)) \ + ((!ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \ || _PyArg_CheckPositional((funcname), (nargs), (min), (max))) #endif @@ -127,6 +128,14 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( struct _PyArg_Parser *parser, int minpos, int maxpos, int minkw, PyObject **buf); + +PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg( + PyObject *const *args, Py_ssize_t nargs, + PyObject *kwargs, PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, int maxpos, int minkw, + int vararg, PyObject **buf); + #define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ (minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \ |