diff -r 496e094f4734 -r 34456cce64bb .hgignore --- a/.hgignore Thu Apr 21 00:23:08 2016 -0700 +++ b/.hgignore Thu May 19 13:47:42 2016 +0200 @@ -98,3 +98,6 @@ coverage.info Tools/msi/obj Tools/ssl/amd64 Tools/ssl/win32 +rel/ +dbg/ +pgo/ diff -r 496e094f4734 -r 34456cce64bb Doc/includes/shoddy.c --- a/Doc/includes/shoddy.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Doc/includes/shoddy.c Thu May 19 13:47:42 2016 +0200 @@ -23,7 +23,7 @@ static PyMethodDef Shoddy_methods[] = { static int Shoddy_init(Shoddy *self, PyObject *args, PyObject *kwds) { - if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0) + if (_PyType_CallInit(&PyList_Type, (PyObject *)self, args, kwds) < 0) return -1; self->state = 0; return 0; diff -r 496e094f4734 -r 34456cce64bb Include/Python.h --- a/Include/Python.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/Python.h Thu May 19 13:47:42 2016 +0200 @@ -112,6 +112,7 @@ #include "pyarena.h" #include "modsupport.h" +#include "pystack.h" #include "pythonrun.h" #include "pylifecycle.h" #include "ceval.h" diff -r 496e094f4734 -r 34456cce64bb Include/abstract.h --- a/Include/abstract.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/abstract.h Thu May 19 13:47:42 2016 +0200 @@ -263,9 +263,17 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx This function always succeeds. */ - PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, + PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *func, PyObject *args, PyObject *kw); + PyAPI_FUNC(PyObject *) _PyObject_FastCall(PyObject *func, + PyObject **stack, + int nargs, PyObject *kwargs); + + + PyAPI_FUNC(PyObject *) PyObject_CallNoArg(PyObject *func); + PyAPI_FUNC(PyObject *) PyObject_CallArg1(PyObject *func, PyObject *arg); + #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func, PyObject *result, @@ -291,6 +299,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object, const char *format, ...); + PyAPI_FUNC(PyObject *) _PyObject_CallVaFunction(PyObject *callable, + const char *format, + va_list vargs); /* Call a callable Python object, callable_object, with a @@ -305,6 +316,10 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, const char *method, const char *format, ...); + PyAPI_FUNC(PyObject *) _PyObject_CallVaMethod(PyObject *o, + const char *name, + const char *format, + va_list vargs); /* Call the method named m of object o with a variable number of diff -r 496e094f4734 -r 34456cce64bb Include/descrobject.h --- a/Include/descrobject.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/descrobject.h Thu May 19 13:47:42 2016 +0200 @@ -20,9 +20,16 @@ typedef struct PyGetSetDef { typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, void *wrapped); +typedef PyObject *(*fastwrapperfunc)(PyObject *self, PyObject **stack, int na, + void *wrapped); + typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds); +typedef PyObject *(*wrapperfunc_fast)(PyObject *self, void *wrapped, int flags, + PyObject **stack, int nargs, + PyObject *kwds); + struct wrapperbase { char *name; int offset; @@ -31,10 +38,12 @@ struct wrapperbase { char *doc; int flags; PyObject *name_strobj; + fastwrapperfunc fastwrapper; }; /* Flags for above struct */ #define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ +#define PyWrapperFlag_FASTWRAPPER 2 /* wrapper function for tp_init */ /* Various kinds of descriptor objects */ @@ -69,6 +78,7 @@ typedef struct { PyDescr_COMMON; struct wrapperbase *d_base; void *d_wrapped; /* This can be any function pointer */ + int d_type_flags; } PyWrapperDescrObject; #endif /* Py_LIMITED_API */ @@ -90,6 +100,10 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, struct wrapperbase *, void *); +PyAPI_FUNC(PyObject *) _PyDescr_NewWrapperEx(PyTypeObject *type, + struct wrapperbase *base, + void *wrapped, + int type_flags); #define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) #endif diff -r 496e094f4734 -r 34456cce64bb Include/funcobject.h --- a/Include/funcobject.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/funcobject.h Thu May 19 13:47:42 2016 +0200 @@ -58,6 +58,12 @@ PyAPI_FUNC(int) PyFunction_SetClosure(Py PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *); PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyFunction_FastCall( + PyObject *func, + PyObject **stack, + int na, + PyObject *kwargs); + /* Macros for direct access to these values. Type checks are *not* done, so use with care. */ #define PyFunction_GET_CODE(func) \ diff -r 496e094f4734 -r 34456cce64bb Include/methodobject.h --- a/Include/methodobject.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/methodobject.h Thu May 19 13:47:42 2016 +0200 @@ -36,6 +36,10 @@ PyAPI_FUNC(int) PyCFunction_GetFlags(PyO (((PyCFunctionObject *)func) -> m_ml -> ml_flags) #endif PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyCFunction_FastCall(PyObject *self, PyObject **stack, int na, PyObject *kwargs); +PyAPI_FUNC(PyObject *) _PyCFunction_FastCall_FromArgs(PyObject *func, + PyObject *args, PyObject *kwargs); + struct PyMethodDef { const char *ml_name; /* The name of the built-in function/method */ @@ -71,6 +75,8 @@ PyAPI_FUNC(PyObject *) PyCFunction_NewEx #define METH_COEXIST 0x0040 +#define METH_FASTCALL 0x0080 + #ifndef Py_LIMITED_API typedef struct { PyObject_HEAD diff -r 496e094f4734 -r 34456cce64bb Include/modsupport.h --- a/Include/modsupport.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/modsupport.h Thu May 19 13:47:42 2016 +0200 @@ -14,7 +14,9 @@ extern "C" { #ifdef PY_SSIZE_T_CLEAN #define PyArg_Parse _PyArg_Parse_SizeT #define PyArg_ParseTuple _PyArg_ParseTuple_SizeT +#define PyArg_ParseStack _PyArg_ParseStack_SizeT #define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT +#define PyArg_ParseStackAndKeywords _PyArg_ParseStackAndKeywords_SizeT #define PyArg_VaParse _PyArg_VaParse_SizeT #define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT #define Py_BuildValue _Py_BuildValue_SizeT @@ -27,9 +29,13 @@ PyAPI_FUNC(PyObject *) _Py_VaBuildValue_ #if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseStack(PyObject **, int, const char *, ...); PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, const char *, char **, ...); +PyAPI_FUNC(int) PyArg_ParseStackAndKeywords(PyObject **, Py_ssize_t, PyObject *, + const char *, char **, ...); PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *); +PyAPI_FUNC(int) PyArg_UnpackStack(PyObject **, Py_ssize_t, const char *, Py_ssize_t, Py_ssize_t, ...); PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); @@ -44,6 +50,20 @@ PyAPI_FUNC(int) PyArg_VaParseTupleAndKey #endif PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); +/* FIXME: always be size_t safe? or use the macro above? */ +PyAPI_FUNC(PyObject **) Py_BuildStack( + PyObject **small_stack, Py_ssize_t small_stack_len, int *p_na, + const char *format, ...); +PyAPI_FUNC(PyObject **) _Py_BuildStack_SizeT( + PyObject **small_stack, Py_ssize_t small_stack_len, int *p_na, + const char *format, ...); +PyAPI_FUNC(PyObject **) Py_VaBuildStack( + PyObject **small_stack, Py_ssize_t small_stack_len, int *p_na, + const char *format, va_list va); +PyAPI_FUNC(PyObject **) _Py_VaBuildStack_SizeT( + PyObject **small_stack, Py_ssize_t small_stack_len, int *p_na, + const char *, va_list); + PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); diff -r 496e094f4734 -r 34456cce64bb Include/object.h --- a/Include/object.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Include/object.h Thu May 19 13:47:42 2016 +0200 @@ -337,6 +337,10 @@ typedef int (*initproc)(PyObject *, PyOb typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); +/* Fast call calling convention */ +typedef int (*fastinitproc) (PyObject *self, PyObject **stack, int na, PyObject *kwargs); +typedef PyObject* (*fastternaryfunc) (PyObject *self, PyObject **stack, int na, PyObject *kwargs); + #ifdef Py_LIMITED_API typedef struct _typeobject PyTypeObject; /* opaque */ #else @@ -453,6 +457,10 @@ PyAPI_FUNC(PyObject*) PyType_FromSpecWit PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int); #endif +PyAPI_FUNC(PyObject*) _PyType_CallNew(PyTypeObject *type_new, + PyTypeObject *type_arg, + PyObject *args, PyObject *kwds); + #ifndef Py_LIMITED_API /* The *real* layout of a type object when allocated on the heap */ typedef struct _heaptypeobject { @@ -497,6 +505,7 @@ PyAPI_FUNC(int) PyType_Ready(PyTypeObjec PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyType_FastGenericNew(PyTypeObject *type, PyObject **stack, int nargs, PyObject **kwds); #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *); @@ -511,6 +520,8 @@ PyAPI_FUNC(PyObject *) _PyType_GetDocFro PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *); #endif +PyAPI_FUNC(int) _PyType_CallInit(PyTypeObject *type, PyObject *obj, PyObject *args, PyObject *kwds); + /* Generic operations on objects */ struct _Py_Identifier; #ifndef Py_LIMITED_API @@ -626,10 +637,16 @@ given type object has a specified featur /* These two bits are preserved for Stackless Python, next after this is 17 */ #ifdef STACKLESS -#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3UL << 15) -#else +# error "Stackless is no more supported" +#endif #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 -#endif + +/* tp_call, tp_init and tp_new use the "fast call" calling convention: + (PyObject **stack, int nargs, PyObject *kwargs) */ +#define Py_TPFLAGS_FASTNEW (1UL << 15) +#define Py_TPFLAGS_FASTINIT (1UL << 16) +#define Py_TPFLAGS_FASTCALL (1UL << 17) +/* In Python 3.5, bits 15 and 16 were used by stackless */ /* Objects support type attribute cache */ #define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) @@ -648,10 +665,7 @@ given type object has a specified featur #define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) #define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) -#define Py_TPFLAGS_DEFAULT ( \ - Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ - Py_TPFLAGS_HAVE_VERSION_TAG | \ - 0) +#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_HAVE_VERSION_TAG /* NOTE: The following flags reuse lower bits (removed as part of the * Python 3.0 transition). */ diff -r 496e094f4734 -r 34456cce64bb Include/pystack.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Include/pystack.h Thu May 19 13:47:42 2016 +0200 @@ -0,0 +1,64 @@ +#ifndef Py_STACK_H +#define Py_STACK_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Number of PyObject* allocated on the C stack for small Python stack */ +#ifndef Py_DEBUG + /* 10 positional parameters or 5 (key, value) pairs for keyword parameters. + 40 bytes on 32-bit or 80 bytes on 64-bit. */ +# define _PyStack_SIZE 10 +#else + /* In debug mode, only use the buffer allocated on stack for 0, 1 or 2 + objects, to test buffer allocated on the heap. */ +# define _PyStack_SIZE 2 +#endif + +PyAPI_FUNC(PyObject**) _PyStack_Alloc( + PyObject **small_stack, Py_ssize_t small_stack_len, + Py_ssize_t nargs); + +#define _PyStack_ALLOC(small_stack, nargs) \ + _PyStack_Alloc(small_stack, Py_ARRAY_LENGTH(small_stack), nargs) + +PyAPI_FUNC(void) _PyStack_Free(PyObject **stack, + PyObject **small_stack, Py_ssize_t nargs); + +PyAPI_FUNC(PyObject**) _PyStack_Copy( + PyObject **small_stack, Py_ssize_t small_stack_len, + PyObject **stack, int nargs); + +PyAPI_FUNC(PyObject**) _PyStack_FromTuple( + PyObject **small_stack, Py_ssize_t small_stack_len, + PyObject *args, int *p_na); + +PyAPI_FUNC(PyObject**) _PyStack_FromBorrowedTuple( + PyObject *args, Py_ssize_t start, int *p_na); + +PyAPI_FUNC(PyObject**) _PyStack_FromVa( + PyObject **small_stack, Py_ssize_t small_stack_len, + va_list va, int *p_na); + +PyAPI_FUNC(PyObject**) _PyStack_PrependArg( + PyObject **stack, int nargs, + PyObject **small_stack, Py_ssize_t small_stack_len, + PyObject *arg); + +PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack, + Py_ssize_t nargs); + +PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(PyObject **stack, + Py_ssize_t nargs, Py_ssize_t i, Py_ssize_t j); + +PyAPI_FUNC(int) _PyStack_CheckArgs(PyObject **stack, + Py_ssize_t nargs, PyObject *kwargs, + const char *func_name, + Py_ssize_t min_na, Py_ssize_t max_na); + +PyAPI_FUNC(int) _PyStack_CheckArgsKeywords(PyObject **stack, + Py_ssize_t nargs, PyObject *kwargs, + const char *func_name, + Py_ssize_t min_na, Py_ssize_t max_na); + +#endif /* !Py_STACK_H */ diff -r 496e094f4734 -r 34456cce64bb Lib/json/encoder.py --- a/Lib/json/encoder.py Thu Apr 21 00:23:08 2016 -0700 +++ b/Lib/json/encoder.py Thu May 19 13:47:42 2016 +0200 @@ -220,6 +220,7 @@ class JSONEncoder(object): else: _encoder = encode_basestring + # FIXME: avoid nested functions def floatstr(o, allow_nan=self.allow_nan, _repr=float.__repr__, _inf=INFINITY, _neginf=-INFINITY): # Check for specials. Note that this type of test is processor diff -r 496e094f4734 -r 34456cce64bb Lib/test/test_extcall.py --- a/Lib/test/test_extcall.py Thu Apr 21 00:23:08 2016 -0700 +++ b/Lib/test/test_extcall.py Thu May 19 13:47:42 2016 +0200 @@ -305,25 +305,6 @@ TypeError if te dictionary is not empty ... TypeError: id() takes no keyword arguments -A corner case of keyword dictionary items being deleted during -the function call setup. See . - - >>> class Name(str): - ... def __eq__(self, other): - ... try: - ... del x[self] - ... except KeyError: - ... pass - ... return str.__eq__(self, other) - ... def __hash__(self): - ... return str.__hash__(self) - - >>> x = {Name("a"):1, Name("b"):2} - >>> def f(a, b): - ... print(a,b) - >>> f(**x) - 1 2 - Too many arguments: >>> def f(): pass diff -r 496e094f4734 -r 34456cce64bb Lib/test/test_sys.py --- a/Lib/test/test_sys.py Thu Apr 21 00:23:08 2016 -0700 +++ b/Lib/test/test_sys.py Thu May 19 13:47:42 2016 +0200 @@ -931,7 +931,7 @@ class SizeofTest(unittest.TestCase): import collections check(collections.defaultdict.default_factory, size('3PP')) # wrapper_descriptor (descriptor object) - check(int.__add__, size('3P2P')) + check(int.__add__, size('3P2Pi')) # method-wrapper (descriptor object) check({}.__iter__, size('2P')) # dict @@ -1083,9 +1083,9 @@ class SizeofTest(unittest.TestCase): check((1,2,3), vsize('') + 3*self.P) # type # static type: PyTypeObject - s = vsize('P2n15Pl4Pn9Pn11PIP') + s = vsize('P2n15Pl4Pn9Pn11PIP2P') check(int, s) - s = vsize('P2n15Pl4Pn9Pn11PIP' # PyTypeObject + s = vsize('P2n15Pl4Pn9Pn11PIP2P' # PyTypeObject '3P' # PyAsyncMethods '36P' # PyNumberMethods '3P' # PyMappingMethods diff -r 496e094f4734 -r 34456cce64bb Makefile.pre.in --- a/Makefile.pre.in Thu Apr 21 00:23:08 2016 -0700 +++ b/Makefile.pre.in Thu May 19 13:47:42 2016 +0200 @@ -280,16 +280,16 @@ LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@ PGEN= Parser/pgen$(EXE) PSRCS= \ - Parser/acceler.c \ - Parser/grammar1.c \ - Parser/listnode.c \ - Parser/node.c \ - Parser/parser.c \ - Parser/bitset.c \ - Parser/metagrammar.c \ - Parser/firstsets.c \ - Parser/grammar.c \ - Parser/pgen.c + $(srcdir)/Parser/acceler.c \ + $(srcdir)/Parser/grammar1.c \ + $(srcdir)/Parser/listnode.c \ + $(srcdir)/Parser/node.c \ + $(srcdir)/Parser/parser.c \ + $(srcdir)/Parser/bitset.c \ + $(srcdir)/Parser/metagrammar.c \ + $(srcdir)/Parser/firstsets.c \ + $(srcdir)/Parser/grammar.c \ + $(srcdir)/Parser/pgen.c POBJS= \ Parser/acceler.o \ @@ -306,14 +306,14 @@ POBJS= \ PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o PGSRCS= \ - Objects/obmalloc.c \ - Python/dynamic_annotations.c \ - Python/mysnprintf.c \ - Python/pyctype.c \ - Parser/tokenizer_pgen.c \ - Parser/printgrammar.c \ - Parser/parsetok_pgen.c \ - Parser/pgenmain.c + $(srcdir)/Objects/obmalloc.c \ + $(srcdir)/Python/dynamic_annotations.c \ + $(srcdir)/Python/mysnprintf.c \ + $(srcdir)/Python/pyctype.c \ + $(srcdir)/Parser/tokenizer_pgen.c \ + $(srcdir)/Parser/printgrammar.c \ + $(srcdir)/Parser/parsetok_pgen.c \ + $(srcdir)/Parser/pgenmain.c PGOBJS= \ Objects/obmalloc.o \ @@ -412,6 +412,7 @@ PYTHON_OBJS= \ Python/dtoa.o \ Python/formatter_unicode.o \ Python/fileutils.o \ + Python/pystack.o \ Python/$(DYNLOADFILE) \ $(LIBOBJS) \ $(MACHDEP_OBJS) \ diff -r 496e094f4734 -r 34456cce64bb Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_collectionsmodule.c Thu May 19 13:47:42 2016 +0200 @@ -144,7 +144,7 @@ freeblock(block *b) } static PyObject * -deque_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +deque_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { dequeobject *deque; block *b; @@ -483,7 +483,7 @@ deque_copy(PyObject *deque) dequeobject *new_deque; PyObject *rv; - new_deque = (dequeobject *)deque_new(&deque_type, (PyObject *)NULL, (PyObject *)NULL); + new_deque = (dequeobject *)deque_new(&deque_type, NULL, 0, NULL); if (new_deque == NULL) return NULL; new_deque->maxlen = old_deque->maxlen; @@ -1606,8 +1606,8 @@ static PyTypeObject deque_type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTNEW, /* tp_flags */ deque_doc, /* tp_doc */ (traverseproc)deque_traverse, /* tp_traverse */ (inquiry)deque_clear, /* tp_clear */ @@ -1625,7 +1625,7 @@ static PyTypeObject deque_type = { 0, /* tp_dictoffset */ (initproc)deque_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - deque_new, /* tp_new */ + (newfunc)deque_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -1946,7 +1946,7 @@ defdict_missing(defdictobject *dd, PyObj Py_DECREF(tup); return NULL; } - value = PyEval_CallObject(factory, NULL); + value = PyObject_CallNoArg(factory); if (value == NULL) return value; if (PyObject_SetItem((PyObject *)dd, key, value) < 0) { @@ -2130,7 +2130,7 @@ defdict_init(PyObject *self, PyObject *a return -1; Py_XINCREF(newdefault); dd->default_factory = newdefault; - result = PyDict_Type.tp_init(self, newargs, kwds); + result = _PyType_CallInit(&PyDict_Type, self, newargs, kwds); Py_DECREF(newargs); Py_XDECREF(olddefault); return result; diff -r 496e094f4734 -r 34456cce64bb Modules/_csv.c --- a/Modules/_csv.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_csv.c Thu May 19 13:47:42 2016 +0200 @@ -518,15 +518,14 @@ static PyTypeObject Dialect_Type = { static PyObject * _call_dialect(PyObject *dialect_inst, PyObject *kwargs) { - PyObject *ctor_args; - PyObject *dialect; + PyObject *func = (PyObject *)&Dialect_Type; - ctor_args = Py_BuildValue(dialect_inst ? "(O)" : "()", dialect_inst); - if (ctor_args == NULL) - return NULL; - dialect = PyObject_Call((PyObject *)&Dialect_Type, ctor_args, kwargs); - Py_DECREF(ctor_args); - return dialect; + if (dialect_inst) { + return _PyObject_FastCall(func, &dialect_inst, 1, kwargs); + } + else { + return _PyObject_FastCall(func, NULL, 0, kwargs); + } } /* diff -r 496e094f4734 -r 34456cce64bb Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_ctypes/_ctypes.c Thu May 19 13:47:42 2016 +0200 @@ -371,7 +371,7 @@ StructUnionType_new(PyTypeObject *type, /* create the new instance (which is a class, since we are a metatype!) */ - result = (PyTypeObject *)PyType_Type.tp_new(type, args, kwds); + result = (PyTypeObject *)_PyType_CallNew(&PyType_Type, type, args, kwds); if (!result) return NULL; @@ -948,7 +948,7 @@ PyCPointerType_new(PyTypeObject *type, P /* create the new instance (which is a class, since we are a metatype!) */ - result = (PyTypeObject *)PyType_Type.tp_new(type, args, kwds); + result = (PyTypeObject *)_PyType_CallNew(&PyType_Type, type, args, kwds); if (result == NULL) { Py_DECREF((PyObject *)stgdict); return NULL; @@ -1319,7 +1319,7 @@ PyCArrayType_new(PyTypeObject *type, PyO /* create the new instance (which is a class, since we are a metatype!) */ - result = (PyTypeObject *)PyType_Type.tp_new(type, args, kwds); + result = (PyTypeObject *)_PyType_CallNew(&PyType_Type, type, args, kwds); if (result == NULL) return NULL; @@ -1790,7 +1790,7 @@ static PyObject *CreateSwappedType(PyTyp /* create the new instance (which is a class, since we are a metatype!) */ - result = (PyTypeObject *)PyType_Type.tp_new(type, swapped_args, kwds); + result = (PyTypeObject *)_PyType_CallNew(&PyType_Type, type, swapped_args, kwds); Py_DECREF(swapped_args); if (result == NULL) return NULL; @@ -1862,7 +1862,7 @@ PyCSimpleType_new(PyTypeObject *type, Py /* create the new instance (which is a class, since we are a metatype!) */ - result = (PyTypeObject *)PyType_Type.tp_new(type, args, kwds); + result = (PyTypeObject *)_PyType_CallNew(&PyType_Type, type, args, kwds); if (result == NULL) return NULL; @@ -2295,7 +2295,7 @@ PyCFuncPtrType_new(PyTypeObject *type, P /* create the new instance (which is a class, since we are a metatype!) */ - result = (PyTypeObject *)PyType_Type.tp_new(type, args, kwds); + result = (PyTypeObject *)_PyType_CallNew(&PyType_Type, type, args, kwds); if (result == NULL) { Py_DECREF((PyObject *)stgdict); return NULL; diff -r 496e094f4734 -r 34456cce64bb Modules/_ctypes/stgdict.c --- a/Modules/_ctypes/stgdict.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_ctypes/stgdict.c Thu May 19 13:47:42 2016 +0200 @@ -19,7 +19,7 @@ static int PyCStgDict_init(StgDictObject *self, PyObject *args, PyObject *kwds) { - if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0) + if (_PyType_CallInit(&PyDict_Type, (PyObject *)self, args, kwds) < 0) return -1; self->format = NULL; self->ndim = 0; diff -r 496e094f4734 -r 34456cce64bb Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_datetimemodule.c Thu May 19 13:47:42 2016 +0200 @@ -2422,7 +2422,7 @@ static PyGetSetDef date_getset[] = { static char *date_kws[] = {"year", "month", "day", NULL}; static PyObject * -date_new(PyTypeObject *type, PyObject *args, PyObject *kw) +date_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kw) { PyObject *self = NULL; PyObject *state; @@ -2431,8 +2431,8 @@ date_new(PyTypeObject *type, PyObject *a int day; /* Check for invocation from pickle with __getstate__ state */ - if (PyTuple_GET_SIZE(args) == 1 && - PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) && + if (nargs == 1 && + PyBytes_Check(state = stack[0]) && PyBytes_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE && MONTH_IS_SANE(PyBytes_AS_STRING(state)[2])) { @@ -2447,7 +2447,7 @@ date_new(PyTypeObject *type, PyObject *a return (PyObject *)me; } - if (PyArg_ParseTupleAndKeywords(args, kw, "iii", date_kws, + if (PyArg_ParseStackAndKeywords(stack, nargs, kw, "iii", date_kws, &year, &month, &day)) { if (check_date_args(year, month, day) < 0) return NULL; @@ -2756,19 +2756,22 @@ static PyObject * date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw) { PyObject *clone; - PyObject *tuple; int year = GET_YEAR(self); int month = GET_MONTH(self); int day = GET_DAY(self); + PyObject* small_stack[3]; + PyObject** stack; + int nargs; if (! PyArg_ParseTupleAndKeywords(args, kw, "|iii:replace", date_kws, &year, &month, &day)) return NULL; - tuple = Py_BuildValue("iii", year, month, day); - if (tuple == NULL) + stack = Py_BuildStack(small_stack, Py_ARRAY_LENGTH(small_stack), &nargs, + "iii", year, month, day); + if (stack == NULL) return NULL; - clone = date_new(Py_TYPE(self), tuple, NULL); - Py_DECREF(tuple); + clone = date_new(Py_TYPE(self), stack, nargs, NULL); + _PyStack_Free(stack, small_stack, nargs); return clone; } @@ -2920,7 +2923,8 @@ static PyTypeObject PyDateTime_DateType PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_FASTNEW, /* tp_flags */ date_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -2938,7 +2942,7 @@ static PyTypeObject PyDateTime_DateType 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - date_new, /* tp_new */ + (newfunc)date_new, /* tp_new */ 0, /* tp_free */ }; @@ -3076,37 +3080,34 @@ Fail: static PyObject * tzinfo_reduce(PyObject *self) { - PyObject *args, *state, *tmp; + PyObject *args, *state; PyObject *getinitargs, *getstate; _Py_IDENTIFIER(__getinitargs__); _Py_IDENTIFIER(__getstate__); - tmp = PyTuple_New(0); - if (tmp == NULL) - return NULL; - getinitargs = _PyObject_GetAttrId(self, &PyId___getinitargs__); if (getinitargs != NULL) { - args = PyObject_CallObject(getinitargs, tmp); + args = PyObject_CallNoArg(getinitargs); Py_DECREF(getinitargs); if (args == NULL) { - Py_DECREF(tmp); return NULL; } } else { PyErr_Clear(); - args = tmp; - Py_INCREF(args); + + args = PyTuple_New(0); + if (args == NULL) { + return NULL; + } } getstate = _PyObject_GetAttrId(self, &PyId___getstate__); if (getstate != NULL) { - state = PyObject_CallObject(getstate, tmp); + state = PyObject_CallNoArg(getstate); Py_DECREF(getstate); if (state == NULL) { Py_DECREF(args); - Py_DECREF(tmp); return NULL; } } @@ -3120,8 +3121,6 @@ tzinfo_reduce(PyObject *self) Py_INCREF(state); } - Py_DECREF(tmp); - if (state == Py_None) { Py_DECREF(state); return Py_BuildValue("(ON)", Py_TYPE(self), args); diff -r 496e094f4734 -r 34456cce64bb Modules/_elementtree.c --- a/Modules/_elementtree.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_elementtree.c Thu May 19 13:47:42 2016 +0200 @@ -819,8 +819,6 @@ LOCAL(PyObject *) deepcopy(PyObject *object, PyObject *memo) { /* do a deep copy of the given object */ - PyObject *args; - PyObject *result; elementtreestate *st; /* Fast paths */ @@ -857,12 +855,7 @@ deepcopy(PyObject *object, PyObject *mem return NULL; } - args = PyTuple_Pack(2, object, memo); - if (!args) - return NULL; - result = PyObject_CallObject(st->deepcopy_obj, args); - Py_DECREF(args); - return result; + return PyObject_CallFunctionObjArgs(st->deepcopy_obj, object, memo, NULL); } @@ -2729,7 +2722,7 @@ typedef struct { } XMLParserObject; static PyObject* -_elementtree_XMLParser_doctype(XMLParserObject* self, PyObject* args); +_elementtree_XMLParser_doctype(XMLParserObject* self, PyObject** stack, int nargs, PyObject *kwargs); static PyObject * _elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name, PyObject *pubid, PyObject *system); diff -r 496e094f4734 -r 34456cce64bb Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_functoolsmodule.c Thu May 19 13:47:42 2016 +0200 @@ -23,19 +23,19 @@ typedef struct { static PyTypeObject partial_type; static PyObject * -partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) +partial_new(PyTypeObject *type, PyObject **stack, int stack_nargs, PyObject *kw) { PyObject *func, *pargs, *nargs, *pkw; partialobject *pto; - if (PyTuple_GET_SIZE(args) < 1) { + if (stack_nargs < 1) { PyErr_SetString(PyExc_TypeError, "type 'partial' takes at least one argument"); return NULL; } pargs = pkw = NULL; - func = PyTuple_GET_ITEM(args, 0); + func = stack[0]; if (Py_TYPE(func) == &partial_type && type == &partial_type) { partialobject *part = (partialobject *)func; if (part->dict == NULL) { @@ -60,7 +60,7 @@ partial_new(PyTypeObject *type, PyObject pto->fn = func; Py_INCREF(func); - nargs = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX); + nargs = _PyStack_AsTupleSlice(stack, stack_nargs, 1, stack_nargs); if (nargs == NULL) { Py_DECREF(pto); return NULL; @@ -124,26 +124,50 @@ partial_dealloc(partialobject *pto) } static PyObject * -partial_call(partialobject *pto, PyObject *args, PyObject *kw) +partial_call(partialobject *pto, PyObject **stack, int na, PyObject *kw) { PyObject *ret; - PyObject *argappl, *kwappl; + PyObject *kwappl; + PyObject **stack2; + int na2; + PyObject* small_stack[_PyStack_SIZE]; assert (PyCallable_Check(pto->fn)); - assert (PyTuple_Check(pto->args)); assert (PyDict_Check(pto->kw)); if (PyTuple_GET_SIZE(pto->args) == 0) { - argappl = args; - Py_INCREF(args); - } else if (PyTuple_GET_SIZE(args) == 0) { - argappl = pto->args; - Py_INCREF(pto->args); + stack2 = _PyStack_Copy(small_stack, Py_ARRAY_LENGTH(small_stack), + stack, na); + if (stack2 == NULL) { + return NULL; + } + na2 = na; + } else if (na == 0) { + stack2 = _PyStack_FromTuple(small_stack, Py_ARRAY_LENGTH(small_stack), + pto->args, &na2); + if (stack2 == NULL) { + return NULL; + } } else { - argappl = PySequence_Concat(pto->args, args); - if (argappl == NULL) + int a = PyTuple_GET_SIZE(pto->args); + int i; + + na2 = a + na; + stack2 = _PyStack_Alloc(small_stack, Py_ARRAY_LENGTH(small_stack), na2); + if (stack2 == NULL) { return NULL; - assert(PyTuple_Check(argappl)); + } + + for (i=0; iargs, i); + Py_INCREF(obj); + stack2[i] = obj; + } + for (i=0; ikw) == 0) { @@ -152,22 +176,24 @@ partial_call(partialobject *pto, PyObjec } else { kwappl = PyDict_Copy(pto->kw); if (kwappl == NULL) { - Py_DECREF(argappl); - return NULL; + goto error; } if (kw != NULL) { if (PyDict_Merge(kwappl, kw, 1) != 0) { - Py_DECREF(argappl); Py_DECREF(kwappl); - return NULL; + goto error; } } } - ret = PyObject_Call(pto->fn, argappl, kwappl); - Py_DECREF(argappl); + ret = _PyObject_FastCall(pto->fn, stack2, na2, kwappl); + _PyStack_Free(stack2, small_stack, na2); Py_XDECREF(kwappl); return ret; + +error: + _PyStack_Free(stack2, small_stack, na2); + return NULL; } static int @@ -328,8 +354,8 @@ static PyTypeObject partial_type = { PyObject_GenericGetAttr, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTCALL, /* tp_flags */ partial_doc, /* tp_doc */ (traverseproc)partial_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -347,7 +373,7 @@ static PyTypeObject partial_type = { offsetof(partialobject, dict), /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - partial_new, /* tp_new */ + (newfunc)partial_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -455,8 +481,8 @@ keyobject_call(keyobject *ko, PyObject * static PyObject * keyobject_richcompare(PyObject *ko, PyObject *other, int op) { + PyObject *stack[2]; PyObject *res; - PyObject *args; PyObject *x; PyObject *y; PyObject *compare; @@ -485,15 +511,9 @@ keyobject_richcompare(PyObject *ko, PyOb /* Call the user's comparison function and translate the 3-way * result into true or false (or error). */ - args = PyTuple_New(2); - if (args == NULL) - return NULL; - Py_INCREF(x); - Py_INCREF(y); - PyTuple_SET_ITEM(args, 0, x); - PyTuple_SET_ITEM(args, 1, y); - res = PyObject_Call(compare, args, NULL); - Py_DECREF(args); + stack[0] = x; + stack[1] = y; + res = _PyObject_FastCall(compare, stack, 2, NULL); if (res == NULL) return NULL; answer = PyObject_RichCompare(res, zero, op); @@ -543,17 +563,9 @@ functools_reduce(PyObject *self, PyObjec return NULL; } - if ((args = PyTuple_New(2)) == NULL) - goto Fail; - for (;;) { PyObject *op2; - - if (args->ob_refcnt > 1) { - Py_DECREF(args); - if ((args = PyTuple_New(2)) == NULL) - goto Fail; - } + PyObject *stack[2]; op2 = PyIter_Next(it); if (op2 == NULL) { @@ -562,18 +574,18 @@ functools_reduce(PyObject *self, PyObjec break; } - if (result == NULL) + if (result == NULL) { result = op2; + } else { - PyTuple_SetItem(args, 0, result); - PyTuple_SetItem(args, 1, op2); - if ((result = PyEval_CallObject(func, args)) == NULL) + stack[0] = result; + stack[1] = op2; + result = _PyObject_FastCall(func, stack, 2, NULL); + if (result == NULL) goto Fail; } } - Py_DECREF(args); - if (result == NULL) PyErr_SetString(PyExc_TypeError, "reduce() of empty sequence with no initial value"); @@ -582,7 +594,6 @@ functools_reduce(PyObject *self, PyObjec return result; Fail: - Py_XDECREF(args); Py_XDECREF(result); Py_DECREF(it); return NULL; @@ -1225,7 +1236,7 @@ PyInit__functools(void) if (m == NULL) return NULL; - kwd_mark = PyObject_CallObject((PyObject *)&PyBaseObject_Type, NULL); + kwd_mark = PyObject_CallNoArg((PyObject *)&PyBaseObject_Type); if (!kwd_mark) { Py_DECREF(m); return NULL; diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/_iomodule.c.h --- a/Modules/_io/clinic/_iomodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/_iomodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -127,7 +127,7 @@ PyDoc_STRVAR(_io_open__doc__, "opened in a binary mode."); #define _IO_OPEN_METHODDEF \ - {"open", (PyCFunction)_io_open, METH_VARARGS|METH_KEYWORDS, _io_open__doc__}, + {"open", (PyCFunction)_io_open, METH_FASTCALL, _io_open__doc__}, static PyObject * _io_open_impl(PyModuleDef *module, PyObject *file, const char *mode, @@ -135,7 +135,7 @@ static PyObject * const char *newline, int closefd, PyObject *opener); static PyObject * -_io_open(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_io_open(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL}; @@ -148,7 +148,7 @@ static PyObject * int closefd = 1; PyObject *opener = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sizzziO:open", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|sizzziO:open", _keywords, &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) goto exit; return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener); @@ -156,4 +156,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=97cdc09bf68a8064 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ef63f928d596158b input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/bufferedio.c.h --- a/Modules/_io/clinic/bufferedio.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/bufferedio.c.h Thu May 19 13:47:42 2016 +0200 @@ -87,20 +87,22 @@ PyDoc_STRVAR(_io__Buffered_peek__doc__, "\n"); #define _IO__BUFFERED_PEEK_METHODDEF \ - {"peek", (PyCFunction)_io__Buffered_peek, METH_VARARGS, _io__Buffered_peek__doc__}, + {"peek", (PyCFunction)_io__Buffered_peek, METH_FASTCALL, _io__Buffered_peek__doc__}, static PyObject * _io__Buffered_peek_impl(buffered *self, Py_ssize_t size); static PyObject * -_io__Buffered_peek(buffered *self, PyObject *args) +_io__Buffered_peek(buffered *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t size = 0; - if (!PyArg_ParseTuple(args, "|n:peek", + if (!PyArg_ParseStack(stack, nargs, "|n:peek", &size)) goto exit; + if (!_PyArg_NoKeywords("peek()", kwargs)) + goto exit; return_value = _io__Buffered_peek_impl(self, size); exit: @@ -113,20 +115,22 @@ PyDoc_STRVAR(_io__Buffered_read__doc__, "\n"); #define _IO__BUFFERED_READ_METHODDEF \ - {"read", (PyCFunction)_io__Buffered_read, METH_VARARGS, _io__Buffered_read__doc__}, + {"read", (PyCFunction)_io__Buffered_read, METH_FASTCALL, _io__Buffered_read__doc__}, static PyObject * _io__Buffered_read_impl(buffered *self, Py_ssize_t n); static PyObject * -_io__Buffered_read(buffered *self, PyObject *args) +_io__Buffered_read(buffered *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!PyArg_ParseTuple(args, "|O&:read", + if (!PyArg_ParseStack(stack, nargs, "|O&:read", _PyIO_ConvertSsize_t, &n)) goto exit; + if (!_PyArg_NoKeywords("read()", kwargs)) + goto exit; return_value = _io__Buffered_read_impl(self, n); exit: @@ -222,20 +226,22 @@ PyDoc_STRVAR(_io__Buffered_readline__doc "\n"); #define _IO__BUFFERED_READLINE_METHODDEF \ - {"readline", (PyCFunction)_io__Buffered_readline, METH_VARARGS, _io__Buffered_readline__doc__}, + {"readline", (PyCFunction)_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__}, static PyObject * _io__Buffered_readline_impl(buffered *self, Py_ssize_t size); static PyObject * -_io__Buffered_readline(buffered *self, PyObject *args) +_io__Buffered_readline(buffered *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!PyArg_ParseTuple(args, "|O&:readline", + if (!PyArg_ParseStack(stack, nargs, "|O&:readline", _PyIO_ConvertSsize_t, &size)) goto exit; + if (!_PyArg_NoKeywords("readline()", kwargs)) + goto exit; return_value = _io__Buffered_readline_impl(self, size); exit: @@ -248,21 +254,23 @@ PyDoc_STRVAR(_io__Buffered_seek__doc__, "\n"); #define _IO__BUFFERED_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io__Buffered_seek, METH_VARARGS, _io__Buffered_seek__doc__}, + {"seek", (PyCFunction)_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__}, static PyObject * _io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence); static PyObject * -_io__Buffered_seek(buffered *self, PyObject *args) +_io__Buffered_seek(buffered *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *targetobj; int whence = 0; - if (!PyArg_ParseTuple(args, "O|i:seek", + if (!PyArg_ParseStack(stack, nargs, "O|i:seek", &targetobj, &whence)) goto exit; + if (!_PyArg_NoKeywords("seek()", kwargs)) + goto exit; return_value = _io__Buffered_seek_impl(self, targetobj, whence); exit: @@ -275,21 +283,23 @@ PyDoc_STRVAR(_io__Buffered_truncate__doc "\n"); #define _IO__BUFFERED_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)_io__Buffered_truncate, METH_VARARGS, _io__Buffered_truncate__doc__}, + {"truncate", (PyCFunction)_io__Buffered_truncate, METH_FASTCALL, _io__Buffered_truncate__doc__}, static PyObject * _io__Buffered_truncate_impl(buffered *self, PyObject *pos); static PyObject * -_io__Buffered_truncate(buffered *self, PyObject *args) +_io__Buffered_truncate(buffered *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *pos = Py_None; - if (!PyArg_UnpackTuple(args, "truncate", + if (!PyArg_UnpackStack(stack, nargs, "truncate", 0, 1, &pos)) goto exit; + if (!_PyArg_NoKeywords("truncate", kwargs)) + goto exit; return_value = _io__Buffered_truncate_impl(self, pos); exit: @@ -451,4 +461,4 @@ static int exit: return return_value; } -/*[clinic end generated code: output=2bbb5e239b4ffe6f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2e9cb4af5753d5ff input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/bytesio.c.h --- a/Modules/_io/clinic/bytesio.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/bytesio.c.h Thu May 19 13:47:42 2016 +0200 @@ -158,21 +158,23 @@ PyDoc_STRVAR(_io_BytesIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READ_METHODDEF \ - {"read", (PyCFunction)_io_BytesIO_read, METH_VARARGS, _io_BytesIO_read__doc__}, + {"read", (PyCFunction)_io_BytesIO_read, METH_FASTCALL, _io_BytesIO_read__doc__}, static PyObject * _io_BytesIO_read_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_read(bytesio *self, PyObject *args) +_io_BytesIO_read(bytesio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "read", + if (!PyArg_UnpackStack(stack, nargs, "read", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("read", kwargs)) + goto exit; return_value = _io_BytesIO_read_impl(self, arg); exit: @@ -202,21 +204,23 @@ PyDoc_STRVAR(_io_BytesIO_readline__doc__ "Return an empty bytes object at EOF."); #define _IO_BYTESIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)_io_BytesIO_readline, METH_VARARGS, _io_BytesIO_readline__doc__}, + {"readline", (PyCFunction)_io_BytesIO_readline, METH_FASTCALL, _io_BytesIO_readline__doc__}, static PyObject * _io_BytesIO_readline_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_readline(bytesio *self, PyObject *args) +_io_BytesIO_readline(bytesio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "readline", + if (!PyArg_UnpackStack(stack, nargs, "readline", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("readline", kwargs)) + goto exit; return_value = _io_BytesIO_readline_impl(self, arg); exit: @@ -234,21 +238,23 @@ PyDoc_STRVAR(_io_BytesIO_readlines__doc_ "total number of bytes in the lines returned."); #define _IO_BYTESIO_READLINES_METHODDEF \ - {"readlines", (PyCFunction)_io_BytesIO_readlines, METH_VARARGS, _io_BytesIO_readlines__doc__}, + {"readlines", (PyCFunction)_io_BytesIO_readlines, METH_FASTCALL, _io_BytesIO_readlines__doc__}, static PyObject * _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_readlines(bytesio *self, PyObject *args) +_io_BytesIO_readlines(bytesio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "readlines", + if (!PyArg_UnpackStack(stack, nargs, "readlines", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("readlines", kwargs)) + goto exit; return_value = _io_BytesIO_readlines_impl(self, arg); exit: @@ -298,21 +304,23 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__ "The current file position is unchanged. Returns the new size."); #define _IO_BYTESIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_VARARGS, _io_BytesIO_truncate__doc__}, + {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, static PyObject * _io_BytesIO_truncate_impl(bytesio *self, PyObject *arg); static PyObject * -_io_BytesIO_truncate(bytesio *self, PyObject *args) +_io_BytesIO_truncate(bytesio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "truncate", + if (!PyArg_UnpackStack(stack, nargs, "truncate", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("truncate", kwargs)) + goto exit; return_value = _io_BytesIO_truncate_impl(self, arg); exit: @@ -332,21 +340,23 @@ PyDoc_STRVAR(_io_BytesIO_seek__doc__, "Returns the new absolute position."); #define _IO_BYTESIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io_BytesIO_seek, METH_VARARGS, _io_BytesIO_seek__doc__}, + {"seek", (PyCFunction)_io_BytesIO_seek, METH_FASTCALL, _io_BytesIO_seek__doc__}, static PyObject * _io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence); static PyObject * -_io_BytesIO_seek(bytesio *self, PyObject *args) +_io_BytesIO_seek(bytesio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t pos; int whence = 0; - if (!PyArg_ParseTuple(args, "n|i:seek", + if (!PyArg_ParseStack(stack, nargs, "n|i:seek", &pos, &whence)) goto exit; + if (!_PyArg_NoKeywords("seek()", kwargs)) + goto exit; return_value = _io_BytesIO_seek_impl(self, pos, whence); exit: @@ -419,4 +429,4 @@ static int exit: return return_value; } -/*[clinic end generated code: output=164cf0e4117dadbe input=a9049054013a1b77]*/ +/*[clinic end generated code: output=972b030b701ae174 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/fileio.c.h --- a/Modules/_io/clinic/fileio.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/fileio.c.h Thu May 19 13:47:42 2016 +0200 @@ -198,20 +198,22 @@ PyDoc_STRVAR(_io_FileIO_read__doc__, "Return an empty bytes object at EOF."); #define _IO_FILEIO_READ_METHODDEF \ - {"read", (PyCFunction)_io_FileIO_read, METH_VARARGS, _io_FileIO_read__doc__}, + {"read", (PyCFunction)_io_FileIO_read, METH_FASTCALL, _io_FileIO_read__doc__}, static PyObject * _io_FileIO_read_impl(fileio *self, Py_ssize_t size); static PyObject * -_io_FileIO_read(fileio *self, PyObject *args) +_io_FileIO_read(fileio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!PyArg_ParseTuple(args, "|O&:read", + if (!PyArg_ParseStack(stack, nargs, "|O&:read", _PyIO_ConvertSsize_t, &size)) goto exit; + if (!_PyArg_NoKeywords("read()", kwargs)) + goto exit; return_value = _io_FileIO_read_impl(self, size); exit: @@ -267,21 +269,23 @@ PyDoc_STRVAR(_io_FileIO_seek__doc__, "Note that not all file objects are seekable."); #define _IO_FILEIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io_FileIO_seek, METH_VARARGS, _io_FileIO_seek__doc__}, + {"seek", (PyCFunction)_io_FileIO_seek, METH_FASTCALL, _io_FileIO_seek__doc__}, static PyObject * _io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence); static PyObject * -_io_FileIO_seek(fileio *self, PyObject *args) +_io_FileIO_seek(fileio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *pos; int whence = 0; - if (!PyArg_ParseTuple(args, "O|i:seek", + if (!PyArg_ParseStack(stack, nargs, "O|i:seek", &pos, &whence)) goto exit; + if (!_PyArg_NoKeywords("seek()", kwargs)) + goto exit; return_value = _io_FileIO_seek_impl(self, pos, whence); exit: @@ -320,21 +324,23 @@ PyDoc_STRVAR(_io_FileIO_truncate__doc__, "The current file position is changed to the value of size."); #define _IO_FILEIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)_io_FileIO_truncate, METH_VARARGS, _io_FileIO_truncate__doc__}, + {"truncate", (PyCFunction)_io_FileIO_truncate, METH_FASTCALL, _io_FileIO_truncate__doc__}, static PyObject * _io_FileIO_truncate_impl(fileio *self, PyObject *posobj); static PyObject * -_io_FileIO_truncate(fileio *self, PyObject *args) +_io_FileIO_truncate(fileio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *posobj = NULL; - if (!PyArg_UnpackTuple(args, "truncate", + if (!PyArg_UnpackStack(stack, nargs, "truncate", 0, 1, &posobj)) goto exit; + if (!_PyArg_NoKeywords("truncate", kwargs)) + goto exit; return_value = _io_FileIO_truncate_impl(self, posobj); exit: @@ -364,4 +370,4 @@ static PyObject * #ifndef _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ -/*[clinic end generated code: output=b1a20b10c81add64 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=81896e0b0b009a64 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/iobase.c.h --- a/Modules/_io/clinic/iobase.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/iobase.c.h Thu May 19 13:47:42 2016 +0200 @@ -174,20 +174,22 @@ PyDoc_STRVAR(_io__IOBase_readline__doc__ "terminator(s) recognized."); #define _IO__IOBASE_READLINE_METHODDEF \ - {"readline", (PyCFunction)_io__IOBase_readline, METH_VARARGS, _io__IOBase_readline__doc__}, + {"readline", (PyCFunction)_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__}, static PyObject * _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit); static PyObject * -_io__IOBase_readline(PyObject *self, PyObject *args) +_io__IOBase_readline(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t limit = -1; - if (!PyArg_ParseTuple(args, "|O&:readline", + if (!PyArg_ParseStack(stack, nargs, "|O&:readline", _PyIO_ConvertSsize_t, &limit)) goto exit; + if (!_PyArg_NoKeywords("readline()", kwargs)) + goto exit; return_value = _io__IOBase_readline_impl(self, limit); exit: @@ -205,20 +207,22 @@ PyDoc_STRVAR(_io__IOBase_readlines__doc_ "lines so far exceeds hint."); #define _IO__IOBASE_READLINES_METHODDEF \ - {"readlines", (PyCFunction)_io__IOBase_readlines, METH_VARARGS, _io__IOBase_readlines__doc__}, + {"readlines", (PyCFunction)_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__}, static PyObject * _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint); static PyObject * -_io__IOBase_readlines(PyObject *self, PyObject *args) +_io__IOBase_readlines(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t hint = -1; - if (!PyArg_ParseTuple(args, "|O&:readlines", + if (!PyArg_ParseStack(stack, nargs, "|O&:readlines", _PyIO_ConvertSsize_t, &hint)) goto exit; + if (!_PyArg_NoKeywords("readlines()", kwargs)) + goto exit; return_value = _io__IOBase_readlines_impl(self, hint); exit: @@ -239,20 +243,22 @@ PyDoc_STRVAR(_io__RawIOBase_read__doc__, "\n"); #define _IO__RAWIOBASE_READ_METHODDEF \ - {"read", (PyCFunction)_io__RawIOBase_read, METH_VARARGS, _io__RawIOBase_read__doc__}, + {"read", (PyCFunction)_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__}, static PyObject * _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n); static PyObject * -_io__RawIOBase_read(PyObject *self, PyObject *args) +_io__RawIOBase_read(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!PyArg_ParseTuple(args, "|n:read", + if (!PyArg_ParseStack(stack, nargs, "|n:read", &n)) goto exit; + if (!_PyArg_NoKeywords("read()", kwargs)) + goto exit; return_value = _io__RawIOBase_read_impl(self, n); exit: @@ -276,4 +282,4 @@ static PyObject * { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=b874952f5cc248a4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=408f96716aeb4867 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/stringio.c.h --- a/Modules/_io/clinic/stringio.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/stringio.c.h Thu May 19 13:47:42 2016 +0200 @@ -48,21 +48,23 @@ PyDoc_STRVAR(_io_StringIO_read__doc__, "is reached. Return an empty string at EOF."); #define _IO_STRINGIO_READ_METHODDEF \ - {"read", (PyCFunction)_io_StringIO_read, METH_VARARGS, _io_StringIO_read__doc__}, + {"read", (PyCFunction)_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__}, static PyObject * _io_StringIO_read_impl(stringio *self, PyObject *arg); static PyObject * -_io_StringIO_read(stringio *self, PyObject *args) +_io_StringIO_read(stringio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "read", + if (!PyArg_UnpackStack(stack, nargs, "read", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("read", kwargs)) + goto exit; return_value = _io_StringIO_read_impl(self, arg); exit: @@ -78,21 +80,23 @@ PyDoc_STRVAR(_io_StringIO_readline__doc_ "Returns an empty string if EOF is hit immediately."); #define _IO_STRINGIO_READLINE_METHODDEF \ - {"readline", (PyCFunction)_io_StringIO_readline, METH_VARARGS, _io_StringIO_readline__doc__}, + {"readline", (PyCFunction)_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__}, static PyObject * _io_StringIO_readline_impl(stringio *self, PyObject *arg); static PyObject * -_io_StringIO_readline(stringio *self, PyObject *args) +_io_StringIO_readline(stringio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "readline", + if (!PyArg_UnpackStack(stack, nargs, "readline", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("readline", kwargs)) + goto exit; return_value = _io_StringIO_readline_impl(self, arg); exit: @@ -110,21 +114,23 @@ PyDoc_STRVAR(_io_StringIO_truncate__doc_ "Returns the new absolute position."); #define _IO_STRINGIO_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)_io_StringIO_truncate, METH_VARARGS, _io_StringIO_truncate__doc__}, + {"truncate", (PyCFunction)_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__}, static PyObject * _io_StringIO_truncate_impl(stringio *self, PyObject *arg); static PyObject * -_io_StringIO_truncate(stringio *self, PyObject *args) +_io_StringIO_truncate(stringio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!PyArg_UnpackTuple(args, "truncate", + if (!PyArg_UnpackStack(stack, nargs, "truncate", 0, 1, &arg)) goto exit; + if (!_PyArg_NoKeywords("truncate", kwargs)) + goto exit; return_value = _io_StringIO_truncate_impl(self, arg); exit: @@ -144,21 +150,23 @@ PyDoc_STRVAR(_io_StringIO_seek__doc__, "Returns the new absolute position."); #define _IO_STRINGIO_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io_StringIO_seek, METH_VARARGS, _io_StringIO_seek__doc__}, + {"seek", (PyCFunction)_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__}, static PyObject * _io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence); static PyObject * -_io_StringIO_seek(stringio *self, PyObject *args) +_io_StringIO_seek(stringio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t pos; int whence = 0; - if (!PyArg_ParseTuple(args, "n|i:seek", + if (!PyArg_ParseStack(stack, nargs, "n|i:seek", &pos, &whence)) goto exit; + if (!_PyArg_NoKeywords("seek()", kwargs)) + goto exit; return_value = _io_StringIO_seek_impl(self, pos, whence); exit: @@ -283,4 +291,4 @@ static PyObject * { return _io_StringIO_seekable_impl(self); } -/*[clinic end generated code: output=f061cf3a20cd14ed input=a9049054013a1b77]*/ +/*[clinic end generated code: output=716f80f8ba64b6fc input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/clinic/textio.c.h --- a/Modules/_io/clinic/textio.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/clinic/textio.c.h Thu May 19 13:47:42 2016 +0200 @@ -44,21 +44,21 @@ PyDoc_STRVAR(_io_IncrementalNewlineDecod "\n"); #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \ - {"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_VARARGS|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, + {"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_FASTCALL, _io_IncrementalNewlineDecoder_decode__doc__}, static PyObject * _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self, PyObject *input, int final); static PyObject * -_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *args, PyObject *kwargs) +_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"input", "final", NULL}; PyObject *input; int final = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:decode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|i:decode", _keywords, &input, &final)) goto exit; return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final); @@ -218,20 +218,22 @@ PyDoc_STRVAR(_io_TextIOWrapper_read__doc "\n"); #define _IO_TEXTIOWRAPPER_READ_METHODDEF \ - {"read", (PyCFunction)_io_TextIOWrapper_read, METH_VARARGS, _io_TextIOWrapper_read__doc__}, + {"read", (PyCFunction)_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__}, static PyObject * _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n); static PyObject * -_io_TextIOWrapper_read(textio *self, PyObject *args) +_io_TextIOWrapper_read(textio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!PyArg_ParseTuple(args, "|O&:read", + if (!PyArg_ParseStack(stack, nargs, "|O&:read", _PyIO_ConvertSsize_t, &n)) goto exit; + if (!_PyArg_NoKeywords("read()", kwargs)) + goto exit; return_value = _io_TextIOWrapper_read_impl(self, n); exit: @@ -244,20 +246,22 @@ PyDoc_STRVAR(_io_TextIOWrapper_readline_ "\n"); #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \ - {"readline", (PyCFunction)_io_TextIOWrapper_readline, METH_VARARGS, _io_TextIOWrapper_readline__doc__}, + {"readline", (PyCFunction)_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, static PyObject * _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size); static PyObject * -_io_TextIOWrapper_readline(textio *self, PyObject *args) +_io_TextIOWrapper_readline(textio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!PyArg_ParseTuple(args, "|n:readline", + if (!PyArg_ParseStack(stack, nargs, "|n:readline", &size)) goto exit; + if (!_PyArg_NoKeywords("readline()", kwargs)) + goto exit; return_value = _io_TextIOWrapper_readline_impl(self, size); exit: @@ -270,21 +274,23 @@ PyDoc_STRVAR(_io_TextIOWrapper_seek__doc "\n"); #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ - {"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_VARARGS, _io_TextIOWrapper_seek__doc__}, + {"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, static PyObject * _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); static PyObject * -_io_TextIOWrapper_seek(textio *self, PyObject *args) +_io_TextIOWrapper_seek(textio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *cookieObj; int whence = 0; - if (!PyArg_ParseTuple(args, "O|i:seek", + if (!PyArg_ParseStack(stack, nargs, "O|i:seek", &cookieObj, &whence)) goto exit; + if (!_PyArg_NoKeywords("seek()", kwargs)) + goto exit; return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence); exit: @@ -314,21 +320,23 @@ PyDoc_STRVAR(_io_TextIOWrapper_truncate_ "\n"); #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_VARARGS, _io_TextIOWrapper_truncate__doc__}, + {"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, static PyObject * _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos); static PyObject * -_io_TextIOWrapper_truncate(textio *self, PyObject *args) +_io_TextIOWrapper_truncate(textio *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *pos = Py_None; - if (!PyArg_UnpackTuple(args, "truncate", + if (!PyArg_UnpackStack(stack, nargs, "truncate", 0, 1, &pos)) goto exit; + if (!_PyArg_NoKeywords("truncate", kwargs)) + goto exit; return_value = _io_TextIOWrapper_truncate_impl(self, pos); exit: @@ -453,4 +461,4 @@ static PyObject * { return _io_TextIOWrapper_close_impl(self); } -/*[clinic end generated code: output=690608f85aab8ba5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=dcff8a1d3e1ff546 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/_io/iobase.c --- a/Modules/_io/iobase.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_io/iobase.c Thu May 19 13:47:42 2016 +0200 @@ -442,7 +442,7 @@ iobase_enter(PyObject *self, PyObject *a } static PyObject * -iobase_exit(PyObject *self, PyObject *args) +iobase_exit(PyObject *self, PyObject **stack, int nargs, PyObject *kwards) { return PyObject_CallMethodObjArgs(self, _PyIO_str_close, NULL); } @@ -762,7 +762,7 @@ static PyMethodDef iobase_methods[] = { _IO__IOBASE_ISATTY_METHODDEF {"__enter__", iobase_enter, METH_NOARGS}, - {"__exit__", iobase_exit, METH_VARARGS}, + {"__exit__", (PyCFunction)iobase_exit, METH_FASTCALL}, _IO__IOBASE_READLINE_METHODDEF _IO__IOBASE_READLINES_METHODDEF diff -r 496e094f4734 -r 34456cce64bb Modules/_json.c --- a/Modules/_json.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_json.c Thu May 19 13:47:42 2016 +0200 @@ -95,10 +95,6 @@ static void scanner_dealloc(PyObject *self); static int scanner_clear(PyObject *self); -static PyObject * -encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds); -static int -encoder_init(PyObject *self, PyObject *args, PyObject *kwds); static void encoder_dealloc(PyObject *self); static int @@ -1311,7 +1307,7 @@ PyTypeObject PyScannerType = { }; static PyObject * -encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +encoder_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyEncoderObject *s; s = (PyEncoderObject *)type->tp_alloc(type, 0); @@ -1329,7 +1325,7 @@ encoder_new(PyTypeObject *type, PyObject } static int -encoder_init(PyObject *self, PyObject *args, PyObject *kwds) +encoder_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { /* initialize Encoder object */ static char *kwlist[] = {"markers", "default", "encoder", "indent", "key_separator", "item_separator", "sort_keys", "skipkeys", "allow_nan", NULL}; @@ -1342,7 +1338,7 @@ encoder_init(PyObject *self, PyObject *a assert(PyEncoder_Check(self)); s = (PyEncoderObject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOUUOOp:make_encoder", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "OOOOUUOOp:make_encoder", kwlist, &markers, &defaultfn, &encoder, &indent, &key_separator, &item_separator, &sort_keys, &skipkeys, &allow_nan)) @@ -1385,7 +1381,7 @@ encoder_init(PyObject *self, PyObject *a } static PyObject * -encoder_call(PyObject *self, PyObject *args, PyObject *kwds) +encoder_call(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { /* Python callable interface to encode_listencode_obj */ static char *kwlist[] = {"obj", "_current_indent_level", NULL}; @@ -1396,7 +1392,7 @@ encoder_call(PyObject *self, PyObject *a assert(PyEncoder_Check(self)); s = (PyEncoderObject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "On:_iterencode", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "On:_iterencode", kwlist, &obj, &indent_level)) return NULL; if (_PyAccu_Init(&acc)) @@ -1888,12 +1884,13 @@ PyTypeObject PyEncoderType = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - encoder_call, /* tp_call */ + (ternaryfunc)encoder_call, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT | Py_TPFLAGS_FASTCALL, /* tp_flags */ encoder_doc, /* tp_doc */ encoder_traverse, /* tp_traverse */ encoder_clear, /* tp_clear */ @@ -1909,10 +1906,9 @@ PyTypeObject PyEncoderType = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - encoder_init, /* tp_init */ + (initproc)encoder_init, /* tp_init */ 0, /* tp_alloc */ - encoder_new, /* tp_new */ - 0, /* tp_free */ + (newfunc)encoder_new, /* tp_new */ }; static PyMethodDef speedups_methods[] = { diff -r 496e094f4734 -r 34456cce64bb Modules/_lsprof.c --- a/Modules/_lsprof.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_lsprof.c Thu May 19 13:47:42 2016 +0200 @@ -119,12 +119,11 @@ static PyTypeObject PyProfiler_Type; /*** External Timers ***/ #define DOUBLE_TIMER_PRECISION 4294967296.0 -static PyObject *empty_tuple; static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj) { PY_LONG_LONG result; - PyObject *o = PyObject_Call(pObj->externalTimer, empty_tuple, NULL); + PyObject *o = PyObject_CallNoArg(pObj->externalTimer); if (o == NULL) { PyErr_WriteUnraisable(pObj->externalTimer); return 0; @@ -889,7 +888,6 @@ PyInit__lsprof(void) (PyObject*) &StatsEntryType); PyModule_AddObject(module, "profiler_subentry", (PyObject*) &StatsSubEntryType); - empty_tuple = PyTuple_New(0); initialized = 1; return module; } diff -r 496e094f4734 -r 34456cce64bb Modules/_operator.c --- a/Modules/_operator.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_operator.c Thu May 19 13:47:42 2016 +0200 @@ -455,12 +455,15 @@ itemgetter_traverse(itemgetterobject *ig } static PyObject * -itemgetter_call(itemgetterobject *ig, PyObject *args, PyObject *kw) +itemgetter_call(PyObject *self, PyObject **stack, int nargs, PyObject *kw) { + itemgetterobject *ig = (itemgetterobject *)self; PyObject *obj, *result; Py_ssize_t i, nitems=ig->nitems; - if (!PyArg_UnpackTuple(args, "itemgetter", 1, 1, &obj)) + if (!_PyArg_NoKeywords("itemgetter", kw)) + return NULL; + if (!PyArg_UnpackStack(stack, nargs, "itemgetter", 1, 1, &obj)) return NULL; if (nitems == 1) return PyObject_GetItem(obj, ig->item); @@ -548,7 +551,7 @@ static PyTypeObject itemgetter_type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTCALL, /* tp_flags */ itemgetter_doc, /* tp_doc */ (traverseproc)itemgetter_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -567,7 +570,6 @@ static PyTypeObject itemgetter_type = { 0, /* tp_init */ 0, /* tp_alloc */ itemgetter_new, /* tp_new */ - 0, /* tp_free */ }; @@ -1122,6 +1124,7 @@ methodcaller_reduce(methodcallerobject * PyTuple_SET_ITEM(newargs, 0, (PyObject *)Py_TYPE(mc)); Py_INCREF(mc->name); PyTuple_SET_ITEM(newargs, 1, mc->name); + /* FIXME: fastcall */ constructor = PyObject_Call(partial, newargs, mc->kwds); Py_DECREF(newargs); Py_DECREF(partial); diff -r 496e094f4734 -r 34456cce64bb Modules/_pickle.c --- a/Modules/_pickle.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_pickle.c Thu May 19 13:47:42 2016 +0200 @@ -338,36 +338,6 @@ static int return -1; } -/* Helper for calling a function with a single argument quickly. - - This function steals the reference of the given argument. */ -static PyObject * -_Pickle_FastCall(PyObject *func, PyObject *obj) -{ - PyObject *result; - PyObject *arg_tuple = PyTuple_New(1); - - /* Note: this function used to reuse the argument tuple. This used to give - a slight performance boost with older pickle implementations where many - unbuffered reads occurred (thus needing many function calls). - - However, this optimization was removed because it was too complicated - to get right. It abused the C API for tuples to mutate them which led - to subtle reference counting and concurrency bugs. Furthermore, the - introduction of protocol 4 and the prefetching optimization via peek() - significantly reduced the number of function calls we do. Thus, the - benefits became marginal at best. */ - - if (arg_tuple == NULL) { - Py_DECREF(obj); - return NULL; - } - PyTuple_SET_ITEM(arg_tuple, 0, obj); - result = PyObject_Call(func, arg_tuple, NULL); - Py_CLEAR(arg_tuple); - return result; -} - /*************************************************************************/ /* Internal data type used as the unpickling stack. */ @@ -958,7 +928,8 @@ static int if (output == NULL) return -1; - result = _Pickle_FastCall(self->write, output); + result = PyObject_CallArg1(self->write, output); + Py_DECREF(output); Py_XDECREF(result); return (result == NULL) ? -1 : 0; } @@ -1157,9 +1128,7 @@ static Py_ssize_t return -1; if (n == READ_WHOLE_LINE) { - PyObject *empty_tuple = PyTuple_New(0); - data = PyObject_Call(self->readline, empty_tuple, NULL); - Py_DECREF(empty_tuple); + data = PyObject_CallNoArg(self->readline); } else { PyObject *len; @@ -1168,7 +1137,8 @@ static Py_ssize_t len = PyLong_FromSsize_t(PREFETCH); if (len == NULL) return -1; - data = _Pickle_FastCall(self->peek, len); + data = PyObject_CallArg1(self->peek, len); + Py_DECREF(len); if (data == NULL) { if (!PyErr_ExceptionMatches(PyExc_NotImplementedError)) return -1; @@ -1187,7 +1157,8 @@ static Py_ssize_t len = PyLong_FromSsize_t(n); if (len == NULL) return -1; - data = _Pickle_FastCall(self->read, len); + data = PyObject_CallArg1(self->read, len); + Py_DECREF(len); } if (data == NULL) return -1; @@ -1211,7 +1182,7 @@ static Py_ssize_t Returns -1 (with an exception set) on failure. On success, return the number of chars read. */ static Py_ssize_t -_Unpickler_Read(UnpicklerObject *self, char **s, Py_ssize_t n) +_Unpickler_ReadImpl(UnpicklerObject *self, char **s, Py_ssize_t n) { Py_ssize_t num_read; @@ -1243,6 +1214,14 @@ static Py_ssize_t return n; } +#define _Unpickler_Read(self, s, n) \ + ((self->next_read_idx <= PY_SSIZE_T_MAX - (n) \ + && self->next_read_idx + (n) <= self->input_len) \ + ? (*(s) = self->input_buffer + self->next_read_idx, \ + self->next_read_idx += (n), \ + (n)) \ + : _Unpickler_ReadImpl(self, (s), (n))) + static Py_ssize_t _Unpickler_CopyLine(UnpicklerObject *self, char *line, Py_ssize_t len, char **result) @@ -3422,7 +3401,8 @@ save_pers(PicklerObject *self, PyObject const char binpersid_op = BINPERSID; Py_INCREF(obj); - pid = _Pickle_FastCall(func, obj); + pid = PyObject_CallArg1(func, obj); + Py_DECREF(obj); if (pid == NULL) return -1; @@ -3905,7 +3885,8 @@ save(PicklerObject *self, PyObject *obj, } if (reduce_func != NULL) { Py_INCREF(obj); - reduce_value = _Pickle_FastCall(reduce_func, obj); + reduce_value = PyObject_CallArg1(reduce_func, obj); + Py_DECREF(obj); } else if (PyType_IsSubtype(type, &PyType_Type)) { status = save_global(self, obj, NULL); @@ -3930,7 +3911,8 @@ save(PicklerObject *self, PyObject *obj, PyObject *proto; proto = PyLong_FromLong(self->proto); if (proto != NULL) { - reduce_value = _Pickle_FastCall(reduce_func, proto); + reduce_value = PyObject_CallArg1(reduce_func, proto); + Py_DECREF(proto); } } else { @@ -3945,10 +3927,7 @@ save(PicklerObject *self, PyObject *obj, /* Check for a __reduce__ method. */ reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__); if (reduce_func != NULL) { - PyObject *empty_tuple = PyTuple_New(0); - reduce_value = PyObject_Call(reduce_func, empty_tuple, - NULL); - Py_DECREF(empty_tuple); + reduce_value = PyObject_CallNoArg(reduce_func); } else { PyErr_Format(st->PicklingError, @@ -5197,7 +5176,7 @@ instantiate(PyObject *cls, PyObject *arg assert(PyTuple_Check(args)); if (Py_SIZE(args) > 0 || !PyType_Check(cls) || _PyObject_HasAttrId(cls, &PyId___getinitargs__)) { - result = PyObject_CallObject(cls, args); + result = PyObject_Call(cls, args, NULL); } else { _Py_IDENTIFIER(__new__); @@ -5328,7 +5307,7 @@ load_newobj(UnpicklerObject *self) } /* Call __new__. */ - obj = cls->tp_new(cls, args, NULL); + obj = _PyType_CallNew(cls, cls, args, NULL); if (obj == NULL) goto error; @@ -5384,7 +5363,7 @@ load_newobj_ex(UnpicklerObject *self) "NEWOBJ_EX class argument doesn't have __new__"); return -1; } - obj = ((PyTypeObject *)cls)->tp_new((PyTypeObject *)cls, args, kwargs); + obj = _PyType_CallNew((PyTypeObject *)cls, (PyTypeObject *)cls, args, kwargs); Py_DECREF(kwargs); Py_DECREF(args); Py_DECREF(cls); @@ -5460,7 +5439,7 @@ load_stack_global(UnpicklerObject *self) static int load_persid(UnpicklerObject *self) { - PyObject *pid; + PyObject *pid, *pid2; Py_ssize_t len; char *s; @@ -5474,13 +5453,12 @@ load_persid(UnpicklerObject *self) if (pid == NULL) return -1; - /* This does not leak since _Pickle_FastCall() steals the reference - to pid first. */ - pid = _Pickle_FastCall(self->pers_func, pid); - if (pid == NULL) + pid2 = PyObject_CallArg1(self->pers_func, pid); + Py_DECREF(pid); + if (pid2 == NULL) return -1; - PDATA_PUSH(self->stack, pid, -1); + PDATA_PUSH(self->stack, pid2, -1); return 0; } else { @@ -5495,20 +5473,21 @@ load_persid(UnpicklerObject *self) static int load_binpersid(UnpicklerObject *self) { - PyObject *pid; + PyObject *pid, *pid2; if (self->pers_func) { PDATA_POP(self->stack, pid); if (pid == NULL) return -1; - /* This does not leak since _Pickle_FastCall() steals the + /* This does not leak since PyObject_CallArg1() steals the reference to pid first. */ - pid = _Pickle_FastCall(self->pers_func, pid); - if (pid == NULL) + pid2 = PyObject_CallArg1(self->pers_func, pid); + Py_DECREF(pid); + if (pid2 == NULL) return -1; - PDATA_PUSH(self->stack, pid, -1); + PDATA_PUSH(self->stack, pid2, -1); return 0; } else { @@ -5863,7 +5842,8 @@ do_append(UnpicklerObject *self, Py_ssiz PyObject *result; value = self->stack->data[i]; - result = _Pickle_FastCall(append_func, value); + result = PyObject_CallArg1(append_func, value); + Py_DECREF(value); if (result == NULL) { Pdata_clear(self->stack, i + 1); Py_SIZE(self->stack) = x; @@ -5990,7 +5970,8 @@ load_additems(UnpicklerObject *self) PyObject *item; item = self->stack->data[i]; - result = _Pickle_FastCall(add_func, item); + result = PyObject_CallArg1(add_func, item); + Py_DECREF(item); if (result == NULL) { Pdata_clear(self->stack, i + 1); Py_SIZE(self->stack) = mark; @@ -6037,7 +6018,8 @@ load_build(UnpicklerObject *self) PyObject *result; /* The explicit __setstate__ is responsible for everything. */ - result = _Pickle_FastCall(setstate, state); + result = PyObject_CallArg1(setstate, state); + Py_DECREF(state); Py_DECREF(setstate); if (result == NULL) return -1; @@ -6170,7 +6152,7 @@ load_reduce(UnpicklerObject *self) return -1; PDATA_POP(self->stack, callable); if (callable) { - obj = PyObject_CallObject(callable, argtup); + obj = PyObject_Call(callable, argtup, NULL); Py_DECREF(callable); } Py_DECREF(argtup); diff -r 496e094f4734 -r 34456cce64bb Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_posixsubprocess.c Thu May 19 13:47:42 2016 +0200 @@ -398,8 +398,7 @@ child_exec(char *const exec_array[], int close_fds, int restore_signals, int call_setsid, PyObject *py_fds_to_keep, - PyObject *preexec_fn, - PyObject *preexec_fn_args_tuple) + PyObject *preexec_fn) { int i, saved_errno, reached_preexec = 0; PyObject *result; @@ -471,9 +470,9 @@ child_exec(char *const exec_array[], #endif reached_preexec = 1; - if (preexec_fn != Py_None && preexec_fn_args_tuple) { + if (preexec_fn != Py_None) { /* This is where the user has asked us to deadlock their program. */ - result = PyObject_Call(preexec_fn, preexec_fn_args_tuple, NULL); + result = PyObject_CallNoArg(preexec_fn); if (result == NULL) { /* Stringifying the exception or traceback would involve * memory allocation and thus potential for deadlock. @@ -548,7 +547,6 @@ subprocess_fork_exec(PyObject* self, PyO PyObject *executable_list, *py_fds_to_keep; PyObject *env_list, *preexec_fn; PyObject *process_args, *converted_args = NULL, *fast_args = NULL; - PyObject *preexec_fn_args_tuple = NULL; int p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite; int errpipe_read, errpipe_write, close_fds, restore_signals; int call_setsid; @@ -652,9 +650,6 @@ subprocess_fork_exec(PyObject* self, PyO } if (preexec_fn != Py_None) { - preexec_fn_args_tuple = PyTuple_New(0); - if (!preexec_fn_args_tuple) - goto cleanup; #ifdef WITH_THREAD _PyImport_AcquireLock(); import_lock_held = 1; @@ -691,7 +686,7 @@ subprocess_fork_exec(PyObject* self, PyO p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, errpipe_read, errpipe_write, close_fds, restore_signals, call_setsid, - py_fds_to_keep, preexec_fn, preexec_fn_args_tuple); + py_fds_to_keep, preexec_fn); _exit(255); return NULL; /* Dead code to avoid a potential compiler warning. */ } @@ -722,7 +717,6 @@ subprocess_fork_exec(PyObject* self, PyO if (_enable_gc(need_to_reenable_gc, gc_module)) { pid = -1; } - Py_XDECREF(preexec_fn_args_tuple); Py_XDECREF(gc_module); if (pid == -1) @@ -743,7 +737,6 @@ cleanup: _Py_FreeCharPArray(exec_array); Py_XDECREF(converted_args); Py_XDECREF(fast_args); - Py_XDECREF(preexec_fn_args_tuple); _enable_gc(need_to_reenable_gc, gc_module); Py_XDECREF(gc_module); return NULL; diff -r 496e094f4734 -r 34456cce64bb Modules/_sre.c --- a/Modules/_sre.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_sre.c Thu May 19 13:47:42 2016 +0200 @@ -734,7 +734,7 @@ call(const char* module, const char* fun Py_DECREF(mod); if (!func) return NULL; - result = PyObject_CallObject(func, args); + result = PyObject_Call(func, args, NULL); Py_DECREF(func); Py_DECREF(args); return result; @@ -1056,7 +1056,6 @@ pattern_subx(PatternObject* self, PyObje PyObject* joiner; PyObject* item; PyObject* filter; - PyObject* args; PyObject* match; void* ptr; Py_ssize_t status; @@ -1158,13 +1157,7 @@ pattern_subx(PatternObject* self, PyObje match = pattern_new_match(self, &state, 1); if (!match) goto error; - args = PyTuple_Pack(1, match); - if (!args) { - Py_DECREF(match); - goto error; - } - item = PyObject_CallObject(filter, args); - Py_DECREF(args); + item = PyObject_CallArg1(filter, match); Py_DECREF(match); if (!item) goto error; diff -r 496e094f4734 -r 34456cce64bb Modules/_ssl.c --- a/Modules/_ssl.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_ssl.c Thu May 19 13:47:42 2016 +0200 @@ -312,7 +312,7 @@ fill_and_set_sslerror(PyObject *type, in int lineno, unsigned long errcode) { PyObject *err_value = NULL, *reason_obj = NULL, *lib_obj = NULL; - PyObject *init_value, *msg, *key; + PyObject *msg, *key; _Py_IDENTIFIER(reason); _Py_IDENTIFIER(library); @@ -355,12 +355,7 @@ fill_and_set_sslerror(PyObject *type, in if (msg == NULL) goto fail; - init_value = Py_BuildValue("iN", ssl_errno, msg); - if (init_value == NULL) - goto fail; - - err_value = PyObject_CallObject(type, init_value); - Py_DECREF(init_value); + err_value = PyObject_CallFunction(type, "iN", ssl_errno, msg); if (err_value == NULL) goto fail; diff -r 496e094f4734 -r 34456cce64bb Modules/_testbuffer.c --- a/Modules/_testbuffer.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_testbuffer.c Thu May 19 13:47:42 2016 +0200 @@ -368,7 +368,7 @@ pack_from_list(PyObject *obj, PyObject * break; } - tmp = PyObject_CallObject(pack_into, args); + tmp = PyObject_Call(pack_into, args, NULL); if (tmp == NULL) { ret = -1; break; @@ -449,7 +449,7 @@ pack_single(char *ptr, PyObject *item, c goto args_out; } - x = PyObject_CallObject(pack_into, args); + x = PyObject_Call(pack_into, args, NULL); if (x != NULL) { Py_DECREF(x); ret = 0; diff -r 496e094f4734 -r 34456cce64bb Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_testcapimodule.c Thu May 19 13:47:42 2016 +0200 @@ -2032,7 +2032,7 @@ static int _pending_callback(void *arg) { /* we assume the argument is callable object to which we own a reference */ PyObject *callable = (PyObject *)arg; - PyObject *r = PyObject_CallObject(callable, NULL); + PyObject *r = PyObject_CallNoArg(callable); Py_DECREF(callable); Py_XDECREF(r); return r != NULL ? 0 : -1; @@ -2806,7 +2806,7 @@ slot_tp_del(PyObject *self) /* Execute __del__ method, if any. */ del = _PyObject_LookupSpecial(self, &PyId___tp_del__); if (del != NULL) { - res = PyEval_CallObject(del, NULL); + res = PyObject_CallNoArg(del); if (res == NULL) PyErr_WriteUnraisable(del); else diff -r 496e094f4734 -r 34456cce64bb Modules/_threadmodule.c --- a/Modules/_threadmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_threadmodule.c Thu May 19 13:47:42 2016 +0200 @@ -95,7 +95,7 @@ acquire_timed(PyThread_type_lock lock, _ } static int -lock_acquire_parse_args(PyObject *args, PyObject *kwds, +lock_acquire_parse_args(PyObject **stack, int nargs, PyObject *kwds, _PyTime_t *timeout) { char *kwlist[] = {"blocking", "timeout", NULL}; @@ -105,7 +105,7 @@ lock_acquire_parse_args(PyObject *args, *timeout = unset_timeout ; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iO:acquire", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|iO:acquire", kwlist, &blocking, &timeout_obj)) return -1; @@ -140,12 +140,12 @@ lock_acquire_parse_args(PyObject *args, } static PyObject * -lock_PyThread_acquire_lock(lockobject *self, PyObject *args, PyObject *kwds) +lock_PyThread_acquire_lock(lockobject *self, PyObject **stack, int nargs, PyObject *kwds) { _PyTime_t timeout; PyLockStatus r; - if (lock_acquire_parse_args(args, kwds, &timeout) < 0) + if (lock_acquire_parse_args(stack, nargs, kwds, &timeout) < 0) return NULL; r = acquire_timed(self->lock_lock, timeout); @@ -170,7 +170,7 @@ and the return value reflects whether th The blocking operation is interruptible."); static PyObject * -lock_PyThread_release_lock(lockobject *self) +lock_PyThread_release_lock(lockobject *self, PyObject **stack, int nargs, PyObject **kwds) { /* Sanity check: the lock must be locked */ if (!self->locked) { @@ -213,9 +213,9 @@ lock_repr(lockobject *self) static PyMethodDef lock_methods[] = { {"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, - METH_VARARGS | METH_KEYWORDS, acquire_doc}, + METH_FASTCALL, acquire_doc}, {"acquire", (PyCFunction)lock_PyThread_acquire_lock, - METH_VARARGS | METH_KEYWORDS, acquire_doc}, + METH_FASTCALL, acquire_doc}, {"release_lock", (PyCFunction)lock_PyThread_release_lock, METH_NOARGS, release_doc}, {"release", (PyCFunction)lock_PyThread_release_lock, @@ -225,9 +225,9 @@ static PyMethodDef lock_methods[] = { {"locked", (PyCFunction)lock_locked_lock, METH_NOARGS, locked_doc}, {"__enter__", (PyCFunction)lock_PyThread_acquire_lock, - METH_VARARGS | METH_KEYWORDS, acquire_doc}, + METH_FASTCALL, acquire_doc}, {"__exit__", (PyCFunction)lock_PyThread_release_lock, - METH_VARARGS, release_doc}, + METH_FASTCALL, release_doc}, {NULL, NULL} /* sentinel */ }; @@ -291,13 +291,13 @@ rlock_dealloc(rlockobject *self) } static PyObject * -rlock_acquire(rlockobject *self, PyObject *args, PyObject *kwds) +rlock_acquire(rlockobject *self, PyObject **stack, int nargs, PyObject *kwds) { _PyTime_t timeout; long tid; PyLockStatus r = PY_LOCK_ACQUIRED; - if (lock_acquire_parse_args(args, kwds, &timeout) < 0) + if (lock_acquire_parse_args(stack, nargs, kwds, &timeout) < 0) return NULL; tid = PyThread_get_thread_ident(); @@ -475,7 +475,7 @@ rlock_repr(rlockobject *self) static PyMethodDef rlock_methods[] = { {"acquire", (PyCFunction)rlock_acquire, - METH_VARARGS | METH_KEYWORDS, rlock_acquire_doc}, + METH_FASTCALL, rlock_acquire_doc}, {"release", (PyCFunction)rlock_release, METH_NOARGS, rlock_release_doc}, {"_is_owned", (PyCFunction)rlock_is_owned, @@ -485,7 +485,7 @@ static PyMethodDef rlock_methods[] = { {"_release_save", (PyCFunction)rlock_release_save, METH_NOARGS, rlock_release_save_doc}, {"__enter__", (PyCFunction)rlock_acquire, - METH_VARARGS | METH_KEYWORDS, rlock_acquire_doc}, + METH_FASTCALL, rlock_acquire_doc}, {"__exit__", (PyCFunction)rlock_release, METH_VARARGS, rlock_release_doc}, {NULL, NULL} /* sentinel */ @@ -827,8 +827,7 @@ static PyObject * return NULL; if (Py_TYPE(self)->tp_init != PyBaseObject_Type.tp_init && - Py_TYPE(self)->tp_init((PyObject*)self, - self->args, self->kw) < 0) { + _PyType_CallInit(Py_TYPE(self), (PyObject*)self, self->args, self->kw) < 0) { /* we need to get rid of ldict from thread so we create a new one the next time we do an attr access */ @@ -995,8 +994,7 @@ t_bootstrap(void *boot_raw) _PyThreadState_Init(tstate); PyEval_AcquireThread(tstate); nb_threads++; - res = PyEval_CallObjectWithKeywords( - boot->func, boot->args, boot->keyw); + res = PyObject_Call(boot->func, boot->args, boot->keyw); if (res == NULL) { if (PyErr_ExceptionMatches(PyExc_SystemExit)) PyErr_Clear(); diff -r 496e094f4734 -r 34456cce64bb Modules/_tkinter.c --- a/Modules/_tkinter.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/_tkinter.c Thu May 19 13:47:42 2016 +0200 @@ -2415,7 +2415,8 @@ PythonCmd(ClientData clientData, Tcl_Int return PythonCmd_Error(interp); } } - res = PyEval_CallObject(func, arg); + /* FIXME: fast call */ + res = PyObject_Call(func, arg, NULL); Py_DECREF(arg); if (res == NULL) @@ -2661,15 +2662,13 @@ static void FileHandler(ClientData clientData, int mask) { FileHandler_ClientData *data = (FileHandler_ClientData *)clientData; - PyObject *func, *file, *arg, *res; + PyObject *func, *file, *res; ENTER_PYTHON func = data->func; file = data->file; - arg = Py_BuildValue("(Oi)", file, (long) mask); - res = PyEval_CallObject(func, arg); - Py_DECREF(arg); + res = PyObject_CallFunction(func, "(Oi)", file, (long) mask); if (res == NULL) { errorInCmd = 1; @@ -2842,7 +2841,7 @@ TimerHandler(ClientData clientData) ENTER_PYTHON - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); Py_DECREF(v); /* See Tktt_New() */ diff -r 496e094f4734 -r 34456cce64bb Modules/arraymodule.c --- a/Modules/arraymodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/arraymodule.c Thu May 19 13:47:42 2016 +0200 @@ -1879,7 +1879,7 @@ typecode_to_mformat_code(char typecode) } /* Forward declaration. */ -static PyObject *array_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +static PyObject *array_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds); /* * Internal: This function wraps the array constructor--i.e., array_new()--to @@ -1895,9 +1895,9 @@ static PyObject *array_new(PyTypeObject static PyObject * make_array(PyTypeObject *arraytype, char typecode, PyObject *items) { - PyObject *new_args; PyObject *array_obj; PyObject *typecode_obj; + PyObject* stack[2]; assert(arraytype != NULL); assert(items != NULL); @@ -1906,15 +1906,11 @@ make_array(PyTypeObject *arraytype, char if (typecode_obj == NULL) return NULL; - new_args = PyTuple_New(2); - if (new_args == NULL) - return NULL; - Py_INCREF(items); - PyTuple_SET_ITEM(new_args, 0, typecode_obj); - PyTuple_SET_ITEM(new_args, 1, items); - - array_obj = array_new(arraytype, new_args, NULL); - Py_DECREF(new_args); + stack[0] = typecode_obj; + stack[1] = items; + array_obj = array_new(arraytype, stack, 2, NULL); + Py_DECREF(typecode_obj); + if (array_obj == NULL) return NULL; @@ -2591,16 +2587,16 @@ static PyBufferProcs array_as_buffer = { }; static PyObject * -array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +array_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { int c; PyObject *initial = NULL, *it = NULL; const struct arraydescr *descr; - if (type == &Arraytype && !_PyArg_NoKeywords("array.array()", kwds)) + if (type == &Arraytype && kwds == NULL && !_PyArg_NoKeywords("array.array()", kwds)) return NULL; - if (!PyArg_ParseTuple(args, "C|O:array", &c, &initial)) + if (!PyArg_ParseStack(stack, nargs, "C|O:array", &c, &initial)) return NULL; if (initial && c != 'u') { @@ -2820,7 +2816,8 @@ static PyTypeObject Arraytype = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_FASTNEW, /* tp_flags */ arraytype_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -2838,7 +2835,7 @@ static PyTypeObject Arraytype = { 0, /* tp_dictoffset */ 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - array_new, /* tp_new */ + (newfunc)array_new, /* tp_new */ PyObject_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Modules/cjkcodecs/clinic/multibytecodec.c.h --- a/Modules/cjkcodecs/clinic/multibytecodec.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h Thu May 19 13:47:42 2016 +0200 @@ -14,7 +14,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteCo "registered with codecs.register_error that can handle UnicodeEncodeErrors."); #define _MULTIBYTECODEC_MULTIBYTECODEC_ENCODE_METHODDEF \ - {"encode", (PyCFunction)_multibytecodec_MultibyteCodec_encode, METH_VARARGS|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__}, + {"encode", (PyCFunction)_multibytecodec_MultibyteCodec_encode, METH_FASTCALL, _multibytecodec_MultibyteCodec_encode__doc__}, static PyObject * _multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self, @@ -22,14 +22,14 @@ static PyObject * const char *errors); static PyObject * -_multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *args, PyObject *kwargs) +_multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"input", "errors", NULL}; PyObject *input; const char *errors = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|z:encode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|z:encode", _keywords, &input, &errors)) goto exit; return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors); @@ -50,7 +50,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteCo "codecs.register_error that is able to handle UnicodeDecodeErrors.\""); #define _MULTIBYTECODEC_MULTIBYTECODEC_DECODE_METHODDEF \ - {"decode", (PyCFunction)_multibytecodec_MultibyteCodec_decode, METH_VARARGS|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__}, + {"decode", (PyCFunction)_multibytecodec_MultibyteCodec_decode, METH_FASTCALL, _multibytecodec_MultibyteCodec_decode__doc__}, static PyObject * _multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self, @@ -58,14 +58,14 @@ static PyObject * const char *errors); static PyObject * -_multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *args, PyObject *kwargs) +_multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"input", "errors", NULL}; Py_buffer input = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|z:decode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|z:decode", _keywords, &input, &errors)) goto exit; return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors); @@ -84,7 +84,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteIn "\n"); #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF \ - {"encode", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_encode, METH_VARARGS|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__}, + {"encode", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_encode, METH_FASTCALL, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__}, static PyObject * _multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEncoderObject *self, @@ -92,14 +92,14 @@ static PyObject * int final); static PyObject * -_multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderObject *self, PyObject *args, PyObject *kwargs) +_multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"input", "final", NULL}; PyObject *input; int final = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:encode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|i:encode", _keywords, &input, &final)) goto exit; return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final); @@ -131,7 +131,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteIn "\n"); #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF \ - {"decode", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_decode, METH_VARARGS|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__}, + {"decode", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_decode, METH_FASTCALL, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__}, static PyObject * _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDecoderObject *self, @@ -139,14 +139,14 @@ static PyObject * int final); static PyObject * -_multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderObject *self, PyObject *args, PyObject *kwargs) +_multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"input", "final", NULL}; Py_buffer input = {NULL, NULL}; int final = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:decode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|i:decode", _keywords, &input, &final)) goto exit; return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final); @@ -182,22 +182,24 @@ PyDoc_STRVAR(_multibytecodec_MultibyteSt "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READ_METHODDEF \ - {"read", (PyCFunction)_multibytecodec_MultibyteStreamReader_read, METH_VARARGS, _multibytecodec_MultibyteStreamReader_read__doc__}, + {"read", (PyCFunction)_multibytecodec_MultibyteStreamReader_read, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__}, static PyObject * _multibytecodec_MultibyteStreamReader_read_impl(MultibyteStreamReaderObject *self, PyObject *sizeobj); static PyObject * -_multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, PyObject *args) +_multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *sizeobj = Py_None; - if (!PyArg_UnpackTuple(args, "read", + if (!PyArg_UnpackStack(stack, nargs, "read", 0, 1, &sizeobj)) goto exit; + if (!_PyArg_NoKeywords("read", kwargs)) + goto exit; return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj); exit: @@ -210,22 +212,24 @@ PyDoc_STRVAR(_multibytecodec_MultibyteSt "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINE_METHODDEF \ - {"readline", (PyCFunction)_multibytecodec_MultibyteStreamReader_readline, METH_VARARGS, _multibytecodec_MultibyteStreamReader_readline__doc__}, + {"readline", (PyCFunction)_multibytecodec_MultibyteStreamReader_readline, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__}, static PyObject * _multibytecodec_MultibyteStreamReader_readline_impl(MultibyteStreamReaderObject *self, PyObject *sizeobj); static PyObject * -_multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self, PyObject *args) +_multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *sizeobj = Py_None; - if (!PyArg_UnpackTuple(args, "readline", + if (!PyArg_UnpackStack(stack, nargs, "readline", 0, 1, &sizeobj)) goto exit; + if (!_PyArg_NoKeywords("readline", kwargs)) + goto exit; return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj); exit: @@ -238,22 +242,24 @@ PyDoc_STRVAR(_multibytecodec_MultibyteSt "\n"); #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINES_METHODDEF \ - {"readlines", (PyCFunction)_multibytecodec_MultibyteStreamReader_readlines, METH_VARARGS, _multibytecodec_MultibyteStreamReader_readlines__doc__}, + {"readlines", (PyCFunction)_multibytecodec_MultibyteStreamReader_readlines, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__}, static PyObject * _multibytecodec_MultibyteStreamReader_readlines_impl(MultibyteStreamReaderObject *self, PyObject *sizehintobj); static PyObject * -_multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *self, PyObject *args) +_multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *sizehintobj = Py_None; - if (!PyArg_UnpackTuple(args, "readlines", + if (!PyArg_UnpackStack(stack, nargs, "readlines", 0, 1, &sizehintobj)) goto exit; + if (!_PyArg_NoKeywords("readlines", kwargs)) + goto exit; return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj); exit: @@ -317,4 +323,4 @@ PyDoc_STRVAR(_multibytecodec___create_co #define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \ {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__}, -/*[clinic end generated code: output=eebb21e18c3043d1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9aac521ec8be1db7 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_bz2module.c.h --- a/Modules/clinic/_bz2module.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_bz2module.c.h Thu May 19 13:47:42 2016 +0200 @@ -111,21 +111,21 @@ PyDoc_STRVAR(_bz2_BZ2Decompressor_decomp "the unused_data attribute."); #define _BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)_bz2_BZ2Decompressor_decompress, METH_VARARGS|METH_KEYWORDS, _bz2_BZ2Decompressor_decompress__doc__}, + {"decompress", (PyCFunction)_bz2_BZ2Decompressor_decompress, METH_FASTCALL, _bz2_BZ2Decompressor_decompress__doc__}, static PyObject * _bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data, Py_ssize_t max_length); static PyObject * -_bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject *args, PyObject *kwargs) +_bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "max_length", NULL}; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|n:decompress", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|n:decompress", _keywords, &data, &max_length)) goto exit; return_value = _bz2_BZ2Decompressor_decompress_impl(self, &data, max_length); @@ -165,4 +165,4 @@ static int exit: return return_value; } -/*[clinic end generated code: output=fef29b76b3314fc7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a8470a74b3ae2829 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_codecsmodule.c.h --- a/Modules/clinic/_codecsmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_codecsmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -54,14 +54,14 @@ PyDoc_STRVAR(_codecs_encode__doc__, "codecs.register_error that can handle ValueErrors."); #define _CODECS_ENCODE_METHODDEF \ - {"encode", (PyCFunction)_codecs_encode, METH_VARARGS|METH_KEYWORDS, _codecs_encode__doc__}, + {"encode", (PyCFunction)_codecs_encode, METH_FASTCALL, _codecs_encode__doc__}, static PyObject * _codecs_encode_impl(PyModuleDef *module, PyObject *obj, const char *encoding, const char *errors); static PyObject * -_codecs_encode(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_codecs_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"obj", "encoding", "errors", NULL}; @@ -69,7 +69,7 @@ static PyObject * const char *encoding = NULL; const char *errors = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:encode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|ss:encode", _keywords, &obj, &encoding, &errors)) goto exit; return_value = _codecs_encode_impl(module, obj, encoding, errors); @@ -91,14 +91,14 @@ PyDoc_STRVAR(_codecs_decode__doc__, "codecs.register_error that can handle ValueErrors."); #define _CODECS_DECODE_METHODDEF \ - {"decode", (PyCFunction)_codecs_decode, METH_VARARGS|METH_KEYWORDS, _codecs_decode__doc__}, + {"decode", (PyCFunction)_codecs_decode, METH_FASTCALL, _codecs_decode__doc__}, static PyObject * _codecs_decode_impl(PyModuleDef *module, PyObject *obj, const char *encoding, const char *errors); static PyObject * -_codecs_decode(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_codecs_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"obj", "encoding", "errors", NULL}; @@ -106,7 +106,7 @@ static PyObject * const char *encoding = NULL; const char *errors = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:decode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|ss:decode", _keywords, &obj, &encoding, &errors)) goto exit; return_value = _codecs_decode_impl(module, obj, encoding, errors); @@ -147,22 +147,24 @@ PyDoc_STRVAR(_codecs_escape_decode__doc_ "\n"); #define _CODECS_ESCAPE_DECODE_METHODDEF \ - {"escape_decode", (PyCFunction)_codecs_escape_decode, METH_VARARGS, _codecs_escape_decode__doc__}, + {"escape_decode", (PyCFunction)_codecs_escape_decode, METH_FASTCALL, _codecs_escape_decode__doc__}, static PyObject * _codecs_escape_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors); static PyObject * -_codecs_escape_decode(PyModuleDef *module, PyObject *args) +_codecs_escape_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "s*|z:escape_decode", + if (!PyArg_ParseStack(stack, nargs, "s*|z:escape_decode", &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("escape_decode()", kwargs)) + goto exit; return_value = _codecs_escape_decode_impl(module, &data, errors); exit: @@ -179,22 +181,24 @@ PyDoc_STRVAR(_codecs_escape_encode__doc_ "\n"); #define _CODECS_ESCAPE_ENCODE_METHODDEF \ - {"escape_encode", (PyCFunction)_codecs_escape_encode, METH_VARARGS, _codecs_escape_encode__doc__}, + {"escape_encode", (PyCFunction)_codecs_escape_encode, METH_FASTCALL, _codecs_escape_encode__doc__}, static PyObject * _codecs_escape_encode_impl(PyModuleDef *module, PyObject *data, const char *errors); static PyObject * -_codecs_escape_encode(PyModuleDef *module, PyObject *args) +_codecs_escape_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *data; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "O!|z:escape_encode", + if (!PyArg_ParseStack(stack, nargs, "O!|z:escape_encode", &PyBytes_Type, &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("escape_encode()", kwargs)) + goto exit; return_value = _codecs_escape_encode_impl(module, data, errors); exit: @@ -207,22 +211,24 @@ PyDoc_STRVAR(_codecs_unicode_internal_de "\n"); #define _CODECS_UNICODE_INTERNAL_DECODE_METHODDEF \ - {"unicode_internal_decode", (PyCFunction)_codecs_unicode_internal_decode, METH_VARARGS, _codecs_unicode_internal_decode__doc__}, + {"unicode_internal_decode", (PyCFunction)_codecs_unicode_internal_decode, METH_FASTCALL, _codecs_unicode_internal_decode__doc__}, static PyObject * _codecs_unicode_internal_decode_impl(PyModuleDef *module, PyObject *obj, const char *errors); static PyObject * -_codecs_unicode_internal_decode(PyModuleDef *module, PyObject *args) +_codecs_unicode_internal_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *obj; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode", + if (!PyArg_ParseStack(stack, nargs, "O|z:unicode_internal_decode", &obj, &errors)) goto exit; + if (!_PyArg_NoKeywords("unicode_internal_decode()", kwargs)) + goto exit; return_value = _codecs_unicode_internal_decode_impl(module, obj, errors); exit: @@ -235,23 +241,25 @@ PyDoc_STRVAR(_codecs_utf_7_decode__doc__ "\n"); #define _CODECS_UTF_7_DECODE_METHODDEF \ - {"utf_7_decode", (PyCFunction)_codecs_utf_7_decode, METH_VARARGS, _codecs_utf_7_decode__doc__}, + {"utf_7_decode", (PyCFunction)_codecs_utf_7_decode, METH_FASTCALL, _codecs_utf_7_decode__doc__}, static PyObject * _codecs_utf_7_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_7_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_7_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_7_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_7_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_7_decode()", kwargs)) + goto exit; return_value = _codecs_utf_7_decode_impl(module, &data, errors, final); exit: @@ -268,23 +276,25 @@ PyDoc_STRVAR(_codecs_utf_8_decode__doc__ "\n"); #define _CODECS_UTF_8_DECODE_METHODDEF \ - {"utf_8_decode", (PyCFunction)_codecs_utf_8_decode, METH_VARARGS, _codecs_utf_8_decode__doc__}, + {"utf_8_decode", (PyCFunction)_codecs_utf_8_decode, METH_FASTCALL, _codecs_utf_8_decode__doc__}, static PyObject * _codecs_utf_8_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_8_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_8_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_8_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_8_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_8_decode()", kwargs)) + goto exit; return_value = _codecs_utf_8_decode_impl(module, &data, errors, final); exit: @@ -301,23 +311,25 @@ PyDoc_STRVAR(_codecs_utf_16_decode__doc_ "\n"); #define _CODECS_UTF_16_DECODE_METHODDEF \ - {"utf_16_decode", (PyCFunction)_codecs_utf_16_decode, METH_VARARGS, _codecs_utf_16_decode__doc__}, + {"utf_16_decode", (PyCFunction)_codecs_utf_16_decode, METH_FASTCALL, _codecs_utf_16_decode__doc__}, static PyObject * _codecs_utf_16_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_16_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_16_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_16_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_16_decode()", kwargs)) + goto exit; return_value = _codecs_utf_16_decode_impl(module, &data, errors, final); exit: @@ -334,23 +346,25 @@ PyDoc_STRVAR(_codecs_utf_16_le_decode__d "\n"); #define _CODECS_UTF_16_LE_DECODE_METHODDEF \ - {"utf_16_le_decode", (PyCFunction)_codecs_utf_16_le_decode, METH_VARARGS, _codecs_utf_16_le_decode__doc__}, + {"utf_16_le_decode", (PyCFunction)_codecs_utf_16_le_decode, METH_FASTCALL, _codecs_utf_16_le_decode__doc__}, static PyObject * _codecs_utf_16_le_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_16_le_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_le_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_16_le_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_16_le_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_16_le_decode()", kwargs)) + goto exit; return_value = _codecs_utf_16_le_decode_impl(module, &data, errors, final); exit: @@ -367,23 +381,25 @@ PyDoc_STRVAR(_codecs_utf_16_be_decode__d "\n"); #define _CODECS_UTF_16_BE_DECODE_METHODDEF \ - {"utf_16_be_decode", (PyCFunction)_codecs_utf_16_be_decode, METH_VARARGS, _codecs_utf_16_be_decode__doc__}, + {"utf_16_be_decode", (PyCFunction)_codecs_utf_16_be_decode, METH_FASTCALL, _codecs_utf_16_be_decode__doc__}, static PyObject * _codecs_utf_16_be_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_16_be_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_be_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_16_be_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_16_be_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_16_be_decode()", kwargs)) + goto exit; return_value = _codecs_utf_16_be_decode_impl(module, &data, errors, final); exit: @@ -401,14 +417,14 @@ PyDoc_STRVAR(_codecs_utf_16_ex_decode__d "\n"); #define _CODECS_UTF_16_EX_DECODE_METHODDEF \ - {"utf_16_ex_decode", (PyCFunction)_codecs_utf_16_ex_decode, METH_VARARGS, _codecs_utf_16_ex_decode__doc__}, + {"utf_16_ex_decode", (PyCFunction)_codecs_utf_16_ex_decode, METH_FASTCALL, _codecs_utf_16_ex_decode__doc__}, static PyObject * _codecs_utf_16_ex_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int byteorder, int final); static PyObject * -_codecs_utf_16_ex_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_ex_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; @@ -416,9 +432,11 @@ static PyObject * int byteorder = 0; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zii:utf_16_ex_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zii:utf_16_ex_decode", &data, &errors, &byteorder, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_16_ex_decode()", kwargs)) + goto exit; return_value = _codecs_utf_16_ex_decode_impl(module, &data, errors, byteorder, final); exit: @@ -435,23 +453,25 @@ PyDoc_STRVAR(_codecs_utf_32_decode__doc_ "\n"); #define _CODECS_UTF_32_DECODE_METHODDEF \ - {"utf_32_decode", (PyCFunction)_codecs_utf_32_decode, METH_VARARGS, _codecs_utf_32_decode__doc__}, + {"utf_32_decode", (PyCFunction)_codecs_utf_32_decode, METH_FASTCALL, _codecs_utf_32_decode__doc__}, static PyObject * _codecs_utf_32_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_32_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_32_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_32_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_32_decode()", kwargs)) + goto exit; return_value = _codecs_utf_32_decode_impl(module, &data, errors, final); exit: @@ -468,23 +488,25 @@ PyDoc_STRVAR(_codecs_utf_32_le_decode__d "\n"); #define _CODECS_UTF_32_LE_DECODE_METHODDEF \ - {"utf_32_le_decode", (PyCFunction)_codecs_utf_32_le_decode, METH_VARARGS, _codecs_utf_32_le_decode__doc__}, + {"utf_32_le_decode", (PyCFunction)_codecs_utf_32_le_decode, METH_FASTCALL, _codecs_utf_32_le_decode__doc__}, static PyObject * _codecs_utf_32_le_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_32_le_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_le_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_32_le_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_32_le_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_32_le_decode()", kwargs)) + goto exit; return_value = _codecs_utf_32_le_decode_impl(module, &data, errors, final); exit: @@ -501,23 +523,25 @@ PyDoc_STRVAR(_codecs_utf_32_be_decode__d "\n"); #define _CODECS_UTF_32_BE_DECODE_METHODDEF \ - {"utf_32_be_decode", (PyCFunction)_codecs_utf_32_be_decode, METH_VARARGS, _codecs_utf_32_be_decode__doc__}, + {"utf_32_be_decode", (PyCFunction)_codecs_utf_32_be_decode, METH_FASTCALL, _codecs_utf_32_be_decode__doc__}, static PyObject * _codecs_utf_32_be_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_utf_32_be_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_be_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:utf_32_be_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:utf_32_be_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_32_be_decode()", kwargs)) + goto exit; return_value = _codecs_utf_32_be_decode_impl(module, &data, errors, final); exit: @@ -535,14 +559,14 @@ PyDoc_STRVAR(_codecs_utf_32_ex_decode__d "\n"); #define _CODECS_UTF_32_EX_DECODE_METHODDEF \ - {"utf_32_ex_decode", (PyCFunction)_codecs_utf_32_ex_decode, METH_VARARGS, _codecs_utf_32_ex_decode__doc__}, + {"utf_32_ex_decode", (PyCFunction)_codecs_utf_32_ex_decode, METH_FASTCALL, _codecs_utf_32_ex_decode__doc__}, static PyObject * _codecs_utf_32_ex_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int byteorder, int final); static PyObject * -_codecs_utf_32_ex_decode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_ex_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; @@ -550,9 +574,11 @@ static PyObject * int byteorder = 0; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zii:utf_32_ex_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zii:utf_32_ex_decode", &data, &errors, &byteorder, &final)) goto exit; + if (!_PyArg_NoKeywords("utf_32_ex_decode()", kwargs)) + goto exit; return_value = _codecs_utf_32_ex_decode_impl(module, &data, errors, byteorder, final); exit: @@ -569,22 +595,24 @@ PyDoc_STRVAR(_codecs_unicode_escape_deco "\n"); #define _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF \ - {"unicode_escape_decode", (PyCFunction)_codecs_unicode_escape_decode, METH_VARARGS, _codecs_unicode_escape_decode__doc__}, + {"unicode_escape_decode", (PyCFunction)_codecs_unicode_escape_decode, METH_FASTCALL, _codecs_unicode_escape_decode__doc__}, static PyObject * _codecs_unicode_escape_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors); static PyObject * -_codecs_unicode_escape_decode(PyModuleDef *module, PyObject *args) +_codecs_unicode_escape_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "s*|z:unicode_escape_decode", + if (!PyArg_ParseStack(stack, nargs, "s*|z:unicode_escape_decode", &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("unicode_escape_decode()", kwargs)) + goto exit; return_value = _codecs_unicode_escape_decode_impl(module, &data, errors); exit: @@ -601,22 +629,24 @@ PyDoc_STRVAR(_codecs_raw_unicode_escape_ "\n"); #define _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF \ - {"raw_unicode_escape_decode", (PyCFunction)_codecs_raw_unicode_escape_decode, METH_VARARGS, _codecs_raw_unicode_escape_decode__doc__}, + {"raw_unicode_escape_decode", (PyCFunction)_codecs_raw_unicode_escape_decode, METH_FASTCALL, _codecs_raw_unicode_escape_decode__doc__}, static PyObject * _codecs_raw_unicode_escape_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors); static PyObject * -_codecs_raw_unicode_escape_decode(PyModuleDef *module, PyObject *args) +_codecs_raw_unicode_escape_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode", + if (!PyArg_ParseStack(stack, nargs, "s*|z:raw_unicode_escape_decode", &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("raw_unicode_escape_decode()", kwargs)) + goto exit; return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors); exit: @@ -633,22 +663,24 @@ PyDoc_STRVAR(_codecs_latin_1_decode__doc "\n"); #define _CODECS_LATIN_1_DECODE_METHODDEF \ - {"latin_1_decode", (PyCFunction)_codecs_latin_1_decode, METH_VARARGS, _codecs_latin_1_decode__doc__}, + {"latin_1_decode", (PyCFunction)_codecs_latin_1_decode, METH_FASTCALL, _codecs_latin_1_decode__doc__}, static PyObject * _codecs_latin_1_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors); static PyObject * -_codecs_latin_1_decode(PyModuleDef *module, PyObject *args) +_codecs_latin_1_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "y*|z:latin_1_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|z:latin_1_decode", &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("latin_1_decode()", kwargs)) + goto exit; return_value = _codecs_latin_1_decode_impl(module, &data, errors); exit: @@ -665,22 +697,24 @@ PyDoc_STRVAR(_codecs_ascii_decode__doc__ "\n"); #define _CODECS_ASCII_DECODE_METHODDEF \ - {"ascii_decode", (PyCFunction)_codecs_ascii_decode, METH_VARARGS, _codecs_ascii_decode__doc__}, + {"ascii_decode", (PyCFunction)_codecs_ascii_decode, METH_FASTCALL, _codecs_ascii_decode__doc__}, static PyObject * _codecs_ascii_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors); static PyObject * -_codecs_ascii_decode(PyModuleDef *module, PyObject *args) +_codecs_ascii_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "y*|z:ascii_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|z:ascii_decode", &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("ascii_decode()", kwargs)) + goto exit; return_value = _codecs_ascii_decode_impl(module, &data, errors); exit: @@ -697,23 +731,25 @@ PyDoc_STRVAR(_codecs_charmap_decode__doc "\n"); #define _CODECS_CHARMAP_DECODE_METHODDEF \ - {"charmap_decode", (PyCFunction)_codecs_charmap_decode, METH_VARARGS, _codecs_charmap_decode__doc__}, + {"charmap_decode", (PyCFunction)_codecs_charmap_decode, METH_FASTCALL, _codecs_charmap_decode__doc__}, static PyObject * _codecs_charmap_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, PyObject *mapping); static PyObject * -_codecs_charmap_decode(PyModuleDef *module, PyObject *args) +_codecs_charmap_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; PyObject *mapping = NULL; - if (!PyArg_ParseTuple(args, "y*|zO:charmap_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zO:charmap_decode", &data, &errors, &mapping)) goto exit; + if (!_PyArg_NoKeywords("charmap_decode()", kwargs)) + goto exit; return_value = _codecs_charmap_decode_impl(module, &data, errors, mapping); exit: @@ -732,23 +768,25 @@ PyDoc_STRVAR(_codecs_mbcs_decode__doc__, "\n"); #define _CODECS_MBCS_DECODE_METHODDEF \ - {"mbcs_decode", (PyCFunction)_codecs_mbcs_decode, METH_VARARGS, _codecs_mbcs_decode__doc__}, + {"mbcs_decode", (PyCFunction)_codecs_mbcs_decode, METH_FASTCALL, _codecs_mbcs_decode__doc__}, static PyObject * _codecs_mbcs_decode_impl(PyModuleDef *module, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_mbcs_decode(PyModuleDef *module, PyObject *args) +_codecs_mbcs_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode", + if (!PyArg_ParseStack(stack, nargs, "y*|zi:mbcs_decode", &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("mbcs_decode()", kwargs)) + goto exit; return_value = _codecs_mbcs_decode_impl(module, &data, errors, final); exit: @@ -769,14 +807,14 @@ PyDoc_STRVAR(_codecs_code_page_decode__d "\n"); #define _CODECS_CODE_PAGE_DECODE_METHODDEF \ - {"code_page_decode", (PyCFunction)_codecs_code_page_decode, METH_VARARGS, _codecs_code_page_decode__doc__}, + {"code_page_decode", (PyCFunction)_codecs_code_page_decode, METH_FASTCALL, _codecs_code_page_decode__doc__}, static PyObject * _codecs_code_page_decode_impl(PyModuleDef *module, int codepage, Py_buffer *data, const char *errors, int final); static PyObject * -_codecs_code_page_decode(PyModuleDef *module, PyObject *args) +_codecs_code_page_decode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int codepage; @@ -784,9 +822,11 @@ static PyObject * const char *errors = NULL; int final = 0; - if (!PyArg_ParseTuple(args, "iy*|zi:code_page_decode", + if (!PyArg_ParseStack(stack, nargs, "iy*|zi:code_page_decode", &codepage, &data, &errors, &final)) goto exit; + if (!_PyArg_NoKeywords("code_page_decode()", kwargs)) + goto exit; return_value = _codecs_code_page_decode_impl(module, codepage, &data, errors, final); exit: @@ -805,22 +845,24 @@ PyDoc_STRVAR(_codecs_readbuffer_encode__ "\n"); #define _CODECS_READBUFFER_ENCODE_METHODDEF \ - {"readbuffer_encode", (PyCFunction)_codecs_readbuffer_encode, METH_VARARGS, _codecs_readbuffer_encode__doc__}, + {"readbuffer_encode", (PyCFunction)_codecs_readbuffer_encode, METH_FASTCALL, _codecs_readbuffer_encode__doc__}, static PyObject * _codecs_readbuffer_encode_impl(PyModuleDef *module, Py_buffer *data, const char *errors); static PyObject * -_codecs_readbuffer_encode(PyModuleDef *module, PyObject *args) +_codecs_readbuffer_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "s*|z:readbuffer_encode", + if (!PyArg_ParseStack(stack, nargs, "s*|z:readbuffer_encode", &data, &errors)) goto exit; + if (!_PyArg_NoKeywords("readbuffer_encode()", kwargs)) + goto exit; return_value = _codecs_readbuffer_encode_impl(module, &data, errors); exit: @@ -837,22 +879,24 @@ PyDoc_STRVAR(_codecs_unicode_internal_en "\n"); #define _CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF \ - {"unicode_internal_encode", (PyCFunction)_codecs_unicode_internal_encode, METH_VARARGS, _codecs_unicode_internal_encode__doc__}, + {"unicode_internal_encode", (PyCFunction)_codecs_unicode_internal_encode, METH_FASTCALL, _codecs_unicode_internal_encode__doc__}, static PyObject * _codecs_unicode_internal_encode_impl(PyModuleDef *module, PyObject *obj, const char *errors); static PyObject * -_codecs_unicode_internal_encode(PyModuleDef *module, PyObject *args) +_codecs_unicode_internal_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *obj; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode", + if (!PyArg_ParseStack(stack, nargs, "O|z:unicode_internal_encode", &obj, &errors)) goto exit; + if (!_PyArg_NoKeywords("unicode_internal_encode()", kwargs)) + goto exit; return_value = _codecs_unicode_internal_encode_impl(module, obj, errors); exit: @@ -865,22 +909,24 @@ PyDoc_STRVAR(_codecs_utf_7_encode__doc__ "\n"); #define _CODECS_UTF_7_ENCODE_METHODDEF \ - {"utf_7_encode", (PyCFunction)_codecs_utf_7_encode, METH_VARARGS, _codecs_utf_7_encode__doc__}, + {"utf_7_encode", (PyCFunction)_codecs_utf_7_encode, METH_FASTCALL, _codecs_utf_7_encode__doc__}, static PyObject * _codecs_utf_7_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_utf_7_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_7_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:utf_7_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:utf_7_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("utf_7_encode()", kwargs)) + goto exit; return_value = _codecs_utf_7_encode_impl(module, str, errors); exit: @@ -893,22 +939,24 @@ PyDoc_STRVAR(_codecs_utf_8_encode__doc__ "\n"); #define _CODECS_UTF_8_ENCODE_METHODDEF \ - {"utf_8_encode", (PyCFunction)_codecs_utf_8_encode, METH_VARARGS, _codecs_utf_8_encode__doc__}, + {"utf_8_encode", (PyCFunction)_codecs_utf_8_encode, METH_FASTCALL, _codecs_utf_8_encode__doc__}, static PyObject * _codecs_utf_8_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_utf_8_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_8_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:utf_8_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:utf_8_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("utf_8_encode()", kwargs)) + goto exit; return_value = _codecs_utf_8_encode_impl(module, str, errors); exit: @@ -921,23 +969,25 @@ PyDoc_STRVAR(_codecs_utf_16_encode__doc_ "\n"); #define _CODECS_UTF_16_ENCODE_METHODDEF \ - {"utf_16_encode", (PyCFunction)_codecs_utf_16_encode, METH_VARARGS, _codecs_utf_16_encode__doc__}, + {"utf_16_encode", (PyCFunction)_codecs_utf_16_encode, METH_FASTCALL, _codecs_utf_16_encode__doc__}, static PyObject * _codecs_utf_16_encode_impl(PyModuleDef *module, PyObject *str, const char *errors, int byteorder); static PyObject * -_codecs_utf_16_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; int byteorder = 0; - if (!PyArg_ParseTuple(args, "U|zi:utf_16_encode", + if (!PyArg_ParseStack(stack, nargs, "U|zi:utf_16_encode", &str, &errors, &byteorder)) goto exit; + if (!_PyArg_NoKeywords("utf_16_encode()", kwargs)) + goto exit; return_value = _codecs_utf_16_encode_impl(module, str, errors, byteorder); exit: @@ -950,22 +1000,24 @@ PyDoc_STRVAR(_codecs_utf_16_le_encode__d "\n"); #define _CODECS_UTF_16_LE_ENCODE_METHODDEF \ - {"utf_16_le_encode", (PyCFunction)_codecs_utf_16_le_encode, METH_VARARGS, _codecs_utf_16_le_encode__doc__}, + {"utf_16_le_encode", (PyCFunction)_codecs_utf_16_le_encode, METH_FASTCALL, _codecs_utf_16_le_encode__doc__}, static PyObject * _codecs_utf_16_le_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_utf_16_le_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_le_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:utf_16_le_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:utf_16_le_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("utf_16_le_encode()", kwargs)) + goto exit; return_value = _codecs_utf_16_le_encode_impl(module, str, errors); exit: @@ -978,22 +1030,24 @@ PyDoc_STRVAR(_codecs_utf_16_be_encode__d "\n"); #define _CODECS_UTF_16_BE_ENCODE_METHODDEF \ - {"utf_16_be_encode", (PyCFunction)_codecs_utf_16_be_encode, METH_VARARGS, _codecs_utf_16_be_encode__doc__}, + {"utf_16_be_encode", (PyCFunction)_codecs_utf_16_be_encode, METH_FASTCALL, _codecs_utf_16_be_encode__doc__}, static PyObject * _codecs_utf_16_be_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_utf_16_be_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_16_be_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:utf_16_be_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:utf_16_be_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("utf_16_be_encode()", kwargs)) + goto exit; return_value = _codecs_utf_16_be_encode_impl(module, str, errors); exit: @@ -1006,23 +1060,25 @@ PyDoc_STRVAR(_codecs_utf_32_encode__doc_ "\n"); #define _CODECS_UTF_32_ENCODE_METHODDEF \ - {"utf_32_encode", (PyCFunction)_codecs_utf_32_encode, METH_VARARGS, _codecs_utf_32_encode__doc__}, + {"utf_32_encode", (PyCFunction)_codecs_utf_32_encode, METH_FASTCALL, _codecs_utf_32_encode__doc__}, static PyObject * _codecs_utf_32_encode_impl(PyModuleDef *module, PyObject *str, const char *errors, int byteorder); static PyObject * -_codecs_utf_32_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; int byteorder = 0; - if (!PyArg_ParseTuple(args, "U|zi:utf_32_encode", + if (!PyArg_ParseStack(stack, nargs, "U|zi:utf_32_encode", &str, &errors, &byteorder)) goto exit; + if (!_PyArg_NoKeywords("utf_32_encode()", kwargs)) + goto exit; return_value = _codecs_utf_32_encode_impl(module, str, errors, byteorder); exit: @@ -1035,22 +1091,24 @@ PyDoc_STRVAR(_codecs_utf_32_le_encode__d "\n"); #define _CODECS_UTF_32_LE_ENCODE_METHODDEF \ - {"utf_32_le_encode", (PyCFunction)_codecs_utf_32_le_encode, METH_VARARGS, _codecs_utf_32_le_encode__doc__}, + {"utf_32_le_encode", (PyCFunction)_codecs_utf_32_le_encode, METH_FASTCALL, _codecs_utf_32_le_encode__doc__}, static PyObject * _codecs_utf_32_le_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_utf_32_le_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_le_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:utf_32_le_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:utf_32_le_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("utf_32_le_encode()", kwargs)) + goto exit; return_value = _codecs_utf_32_le_encode_impl(module, str, errors); exit: @@ -1063,22 +1121,24 @@ PyDoc_STRVAR(_codecs_utf_32_be_encode__d "\n"); #define _CODECS_UTF_32_BE_ENCODE_METHODDEF \ - {"utf_32_be_encode", (PyCFunction)_codecs_utf_32_be_encode, METH_VARARGS, _codecs_utf_32_be_encode__doc__}, + {"utf_32_be_encode", (PyCFunction)_codecs_utf_32_be_encode, METH_FASTCALL, _codecs_utf_32_be_encode__doc__}, static PyObject * _codecs_utf_32_be_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_utf_32_be_encode(PyModuleDef *module, PyObject *args) +_codecs_utf_32_be_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:utf_32_be_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:utf_32_be_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("utf_32_be_encode()", kwargs)) + goto exit; return_value = _codecs_utf_32_be_encode_impl(module, str, errors); exit: @@ -1091,22 +1151,24 @@ PyDoc_STRVAR(_codecs_unicode_escape_enco "\n"); #define _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF \ - {"unicode_escape_encode", (PyCFunction)_codecs_unicode_escape_encode, METH_VARARGS, _codecs_unicode_escape_encode__doc__}, + {"unicode_escape_encode", (PyCFunction)_codecs_unicode_escape_encode, METH_FASTCALL, _codecs_unicode_escape_encode__doc__}, static PyObject * _codecs_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_unicode_escape_encode(PyModuleDef *module, PyObject *args) +_codecs_unicode_escape_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:unicode_escape_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:unicode_escape_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("unicode_escape_encode()", kwargs)) + goto exit; return_value = _codecs_unicode_escape_encode_impl(module, str, errors); exit: @@ -1119,22 +1181,24 @@ PyDoc_STRVAR(_codecs_raw_unicode_escape_ "\n"); #define _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF \ - {"raw_unicode_escape_encode", (PyCFunction)_codecs_raw_unicode_escape_encode, METH_VARARGS, _codecs_raw_unicode_escape_encode__doc__}, + {"raw_unicode_escape_encode", (PyCFunction)_codecs_raw_unicode_escape_encode, METH_FASTCALL, _codecs_raw_unicode_escape_encode__doc__}, static PyObject * _codecs_raw_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_raw_unicode_escape_encode(PyModuleDef *module, PyObject *args) +_codecs_raw_unicode_escape_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:raw_unicode_escape_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:raw_unicode_escape_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("raw_unicode_escape_encode()", kwargs)) + goto exit; return_value = _codecs_raw_unicode_escape_encode_impl(module, str, errors); exit: @@ -1147,22 +1211,24 @@ PyDoc_STRVAR(_codecs_latin_1_encode__doc "\n"); #define _CODECS_LATIN_1_ENCODE_METHODDEF \ - {"latin_1_encode", (PyCFunction)_codecs_latin_1_encode, METH_VARARGS, _codecs_latin_1_encode__doc__}, + {"latin_1_encode", (PyCFunction)_codecs_latin_1_encode, METH_FASTCALL, _codecs_latin_1_encode__doc__}, static PyObject * _codecs_latin_1_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_latin_1_encode(PyModuleDef *module, PyObject *args) +_codecs_latin_1_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:latin_1_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:latin_1_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("latin_1_encode()", kwargs)) + goto exit; return_value = _codecs_latin_1_encode_impl(module, str, errors); exit: @@ -1175,22 +1241,24 @@ PyDoc_STRVAR(_codecs_ascii_encode__doc__ "\n"); #define _CODECS_ASCII_ENCODE_METHODDEF \ - {"ascii_encode", (PyCFunction)_codecs_ascii_encode, METH_VARARGS, _codecs_ascii_encode__doc__}, + {"ascii_encode", (PyCFunction)_codecs_ascii_encode, METH_FASTCALL, _codecs_ascii_encode__doc__}, static PyObject * _codecs_ascii_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_ascii_encode(PyModuleDef *module, PyObject *args) +_codecs_ascii_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:ascii_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:ascii_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("ascii_encode()", kwargs)) + goto exit; return_value = _codecs_ascii_encode_impl(module, str, errors); exit: @@ -1203,23 +1271,25 @@ PyDoc_STRVAR(_codecs_charmap_encode__doc "\n"); #define _CODECS_CHARMAP_ENCODE_METHODDEF \ - {"charmap_encode", (PyCFunction)_codecs_charmap_encode, METH_VARARGS, _codecs_charmap_encode__doc__}, + {"charmap_encode", (PyCFunction)_codecs_charmap_encode, METH_FASTCALL, _codecs_charmap_encode__doc__}, static PyObject * _codecs_charmap_encode_impl(PyModuleDef *module, PyObject *str, const char *errors, PyObject *mapping); static PyObject * -_codecs_charmap_encode(PyModuleDef *module, PyObject *args) +_codecs_charmap_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; PyObject *mapping = NULL; - if (!PyArg_ParseTuple(args, "U|zO:charmap_encode", + if (!PyArg_ParseStack(stack, nargs, "U|zO:charmap_encode", &str, &errors, &mapping)) goto exit; + if (!_PyArg_NoKeywords("charmap_encode()", kwargs)) + goto exit; return_value = _codecs_charmap_encode_impl(module, str, errors, mapping); exit: @@ -1259,22 +1329,24 @@ PyDoc_STRVAR(_codecs_mbcs_encode__doc__, "\n"); #define _CODECS_MBCS_ENCODE_METHODDEF \ - {"mbcs_encode", (PyCFunction)_codecs_mbcs_encode, METH_VARARGS, _codecs_mbcs_encode__doc__}, + {"mbcs_encode", (PyCFunction)_codecs_mbcs_encode, METH_FASTCALL, _codecs_mbcs_encode__doc__}, static PyObject * _codecs_mbcs_encode_impl(PyModuleDef *module, PyObject *str, const char *errors); static PyObject * -_codecs_mbcs_encode(PyModuleDef *module, PyObject *args) +_codecs_mbcs_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "U|z:mbcs_encode", + if (!PyArg_ParseStack(stack, nargs, "U|z:mbcs_encode", &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("mbcs_encode()", kwargs)) + goto exit; return_value = _codecs_mbcs_encode_impl(module, str, errors); exit: @@ -1291,23 +1363,25 @@ PyDoc_STRVAR(_codecs_code_page_encode__d "\n"); #define _CODECS_CODE_PAGE_ENCODE_METHODDEF \ - {"code_page_encode", (PyCFunction)_codecs_code_page_encode, METH_VARARGS, _codecs_code_page_encode__doc__}, + {"code_page_encode", (PyCFunction)_codecs_code_page_encode, METH_FASTCALL, _codecs_code_page_encode__doc__}, static PyObject * _codecs_code_page_encode_impl(PyModuleDef *module, int code_page, PyObject *str, const char *errors); static PyObject * -_codecs_code_page_encode(PyModuleDef *module, PyObject *args) +_codecs_code_page_encode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int code_page; PyObject *str; const char *errors = NULL; - if (!PyArg_ParseTuple(args, "iU|z:code_page_encode", + if (!PyArg_ParseStack(stack, nargs, "iU|z:code_page_encode", &code_page, &str, &errors)) goto exit; + if (!_PyArg_NoKeywords("code_page_encode()", kwargs)) + goto exit; return_value = _codecs_code_page_encode_impl(module, code_page, str, errors); exit: @@ -1327,22 +1401,24 @@ PyDoc_STRVAR(_codecs_register_error__doc "error and must return a (replacement, new position) tuple."); #define _CODECS_REGISTER_ERROR_METHODDEF \ - {"register_error", (PyCFunction)_codecs_register_error, METH_VARARGS, _codecs_register_error__doc__}, + {"register_error", (PyCFunction)_codecs_register_error, METH_FASTCALL, _codecs_register_error__doc__}, static PyObject * _codecs_register_error_impl(PyModuleDef *module, const char *errors, PyObject *handler); static PyObject * -_codecs_register_error(PyModuleDef *module, PyObject *args) +_codecs_register_error(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *errors; PyObject *handler; - if (!PyArg_ParseTuple(args, "sO:register_error", + if (!PyArg_ParseStack(stack, nargs, "sO:register_error", &errors, &handler)) goto exit; + if (!_PyArg_NoKeywords("register_error()", kwargs)) + goto exit; return_value = _codecs_register_error_impl(module, errors, handler); exit: @@ -1393,4 +1469,4 @@ exit: #ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF #define _CODECS_CODE_PAGE_ENCODE_METHODDEF #endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */ -/*[clinic end generated code: output=04007a13c8387689 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2d22aef1c2b36487 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_cryptmodule.c.h --- a/Modules/clinic/_cryptmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_cryptmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -14,24 +14,26 @@ PyDoc_STRVAR(crypt_crypt__doc__, "results for a given *word*."); #define CRYPT_CRYPT_METHODDEF \ - {"crypt", (PyCFunction)crypt_crypt, METH_VARARGS, crypt_crypt__doc__}, + {"crypt", (PyCFunction)crypt_crypt, METH_FASTCALL, crypt_crypt__doc__}, static PyObject * crypt_crypt_impl(PyModuleDef *module, const char *word, const char *salt); static PyObject * -crypt_crypt(PyModuleDef *module, PyObject *args) +crypt_crypt(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *word; const char *salt; - if (!PyArg_ParseTuple(args, "ss:crypt", + if (!PyArg_ParseStack(stack, nargs, "ss:crypt", &word, &salt)) goto exit; + if (!_PyArg_NoKeywords("crypt()", kwargs)) + goto exit; return_value = crypt_crypt_impl(module, word, salt); exit: return return_value; } -/*[clinic end generated code: output=22c295c9bce018c4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=420f7e462dac5a2c input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_datetimemodule.c.h --- a/Modules/clinic/_datetimemodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_datetimemodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -14,19 +14,19 @@ PyDoc_STRVAR(datetime_datetime_now__doc_ "If no tz is specified, uses local timezone."); #define DATETIME_DATETIME_NOW_METHODDEF \ - {"now", (PyCFunction)datetime_datetime_now, METH_VARARGS|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, + {"now", (PyCFunction)datetime_datetime_now, METH_FASTCALL|METH_CLASS, datetime_datetime_now__doc__}, static PyObject * datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz); static PyObject * -datetime_datetime_now(PyTypeObject *type, PyObject *args, PyObject *kwargs) +datetime_datetime_now(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"tz", NULL}; PyObject *tz = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:now", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:now", _keywords, &tz)) goto exit; return_value = datetime_datetime_now_impl(type, tz); @@ -34,4 +34,4 @@ datetime_datetime_now(PyTypeObject *type exit: return return_value; } -/*[clinic end generated code: output=7f45c670d6e4953a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6c85154d3f0cc0b1 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_dbmmodule.c.h --- a/Modules/clinic/_dbmmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_dbmmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -45,23 +45,25 @@ PyDoc_STRVAR(_dbm_dbm_get__doc__, "Return the value for key if present, otherwise default."); #define _DBM_DBM_GET_METHODDEF \ - {"get", (PyCFunction)_dbm_dbm_get, METH_VARARGS, _dbm_dbm_get__doc__}, + {"get", (PyCFunction)_dbm_dbm_get, METH_FASTCALL, _dbm_dbm_get__doc__}, static PyObject * _dbm_dbm_get_impl(dbmobject *self, const char *key, Py_ssize_clean_t key_length, PyObject *default_value); static PyObject * -_dbm_dbm_get(dbmobject *self, PyObject *args) +_dbm_dbm_get(dbmobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *key; Py_ssize_clean_t key_length; PyObject *default_value = NULL; - if (!PyArg_ParseTuple(args, "s#|O:get", + if (!PyArg_ParseStack(stack, nargs, "s#|O:get", &key, &key_length, &default_value)) goto exit; + if (!_PyArg_NoKeywords("get()", kwargs)) + goto exit; return_value = _dbm_dbm_get_impl(self, key, key_length, default_value); exit: @@ -77,7 +79,7 @@ PyDoc_STRVAR(_dbm_dbm_setdefault__doc__, "If key is not in the database, it is inserted with default as the value."); #define _DBM_DBM_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)_dbm_dbm_setdefault, METH_VARARGS, _dbm_dbm_setdefault__doc__}, + {"setdefault", (PyCFunction)_dbm_dbm_setdefault, METH_FASTCALL, _dbm_dbm_setdefault__doc__}, static PyObject * _dbm_dbm_setdefault_impl(dbmobject *self, const char *key, @@ -85,16 +87,18 @@ static PyObject * PyObject *default_value); static PyObject * -_dbm_dbm_setdefault(dbmobject *self, PyObject *args) +_dbm_dbm_setdefault(dbmobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *key; Py_ssize_clean_t key_length; PyObject *default_value = NULL; - if (!PyArg_ParseTuple(args, "s#|O:setdefault", + if (!PyArg_ParseStack(stack, nargs, "s#|O:setdefault", &key, &key_length, &default_value)) goto exit; + if (!_PyArg_NoKeywords("setdefault()", kwargs)) + goto exit; return_value = _dbm_dbm_setdefault_impl(self, key, key_length, default_value); exit: @@ -116,26 +120,28 @@ PyDoc_STRVAR(dbmopen__doc__, " (e.g. os.O_RDWR)."); #define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__}, + {"open", (PyCFunction)dbmopen, METH_FASTCALL, dbmopen__doc__}, static PyObject * dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode); static PyObject * -dbmopen(PyModuleDef *module, PyObject *args) +dbmopen(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *filename; const char *flags = "r"; int mode = 438; - if (!PyArg_ParseTuple(args, "s|si:open", + if (!PyArg_ParseStack(stack, nargs, "s|si:open", &filename, &flags, &mode)) goto exit; + if (!_PyArg_NoKeywords("open()", kwargs)) + goto exit; return_value = dbmopen_impl(module, filename, flags, mode); exit: return return_value; } -/*[clinic end generated code: output=1d92e81b28c558d0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a9b594d82e219c56 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_elementtree.c.h --- a/Modules/clinic/_elementtree.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_elementtree.c.h Thu May 19 13:47:42 2016 +0200 @@ -134,21 +134,21 @@ PyDoc_STRVAR(_elementtree_Element_find__ "\n"); #define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \ - {"find", (PyCFunction)_elementtree_Element_find, METH_VARARGS|METH_KEYWORDS, _elementtree_Element_find__doc__}, + {"find", (PyCFunction)_elementtree_Element_find, METH_FASTCALL, _elementtree_Element_find__doc__}, static PyObject * _elementtree_Element_find_impl(ElementObject *self, PyObject *path, PyObject *namespaces); static PyObject * -_elementtree_Element_find(ElementObject *self, PyObject *args, PyObject *kwargs) +_elementtree_Element_find(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "namespaces", NULL}; PyObject *path; PyObject *namespaces = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:find", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|O:find", _keywords, &path, &namespaces)) goto exit; return_value = _elementtree_Element_find_impl(self, path, namespaces); @@ -163,7 +163,7 @@ PyDoc_STRVAR(_elementtree_Element_findte "\n"); #define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \ - {"findtext", (PyCFunction)_elementtree_Element_findtext, METH_VARARGS|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, + {"findtext", (PyCFunction)_elementtree_Element_findtext, METH_FASTCALL, _elementtree_Element_findtext__doc__}, static PyObject * _elementtree_Element_findtext_impl(ElementObject *self, PyObject *path, @@ -171,7 +171,7 @@ static PyObject * PyObject *namespaces); static PyObject * -_elementtree_Element_findtext(ElementObject *self, PyObject *args, PyObject *kwargs) +_elementtree_Element_findtext(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "default", "namespaces", NULL}; @@ -179,7 +179,7 @@ static PyObject * PyObject *default_value = Py_None; PyObject *namespaces = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:findtext", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|OO:findtext", _keywords, &path, &default_value, &namespaces)) goto exit; return_value = _elementtree_Element_findtext_impl(self, path, default_value, namespaces); @@ -194,21 +194,21 @@ PyDoc_STRVAR(_elementtree_Element_findal "\n"); #define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \ - {"findall", (PyCFunction)_elementtree_Element_findall, METH_VARARGS|METH_KEYWORDS, _elementtree_Element_findall__doc__}, + {"findall", (PyCFunction)_elementtree_Element_findall, METH_FASTCALL, _elementtree_Element_findall__doc__}, static PyObject * _elementtree_Element_findall_impl(ElementObject *self, PyObject *path, PyObject *namespaces); static PyObject * -_elementtree_Element_findall(ElementObject *self, PyObject *args, PyObject *kwargs) +_elementtree_Element_findall(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "namespaces", NULL}; PyObject *path; PyObject *namespaces = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:findall", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|O:findall", _keywords, &path, &namespaces)) goto exit; return_value = _elementtree_Element_findall_impl(self, path, namespaces); @@ -223,21 +223,21 @@ PyDoc_STRVAR(_elementtree_Element_iterfi "\n"); #define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \ - {"iterfind", (PyCFunction)_elementtree_Element_iterfind, METH_VARARGS|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, + {"iterfind", (PyCFunction)_elementtree_Element_iterfind, METH_FASTCALL, _elementtree_Element_iterfind__doc__}, static PyObject * _elementtree_Element_iterfind_impl(ElementObject *self, PyObject *path, PyObject *namespaces); static PyObject * -_elementtree_Element_iterfind(ElementObject *self, PyObject *args, PyObject *kwargs) +_elementtree_Element_iterfind(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "namespaces", NULL}; PyObject *path; PyObject *namespaces = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:iterfind", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|O:iterfind", _keywords, &path, &namespaces)) goto exit; return_value = _elementtree_Element_iterfind_impl(self, path, namespaces); @@ -252,21 +252,21 @@ PyDoc_STRVAR(_elementtree_Element_get__d "\n"); #define _ELEMENTTREE_ELEMENT_GET_METHODDEF \ - {"get", (PyCFunction)_elementtree_Element_get, METH_VARARGS|METH_KEYWORDS, _elementtree_Element_get__doc__}, + {"get", (PyCFunction)_elementtree_Element_get, METH_FASTCALL, _elementtree_Element_get__doc__}, static PyObject * _elementtree_Element_get_impl(ElementObject *self, PyObject *key, PyObject *default_value); static PyObject * -_elementtree_Element_get(ElementObject *self, PyObject *args, PyObject *kwargs) +_elementtree_Element_get(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"key", "default", NULL}; PyObject *key; PyObject *default_value = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:get", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|O:get", _keywords, &key, &default_value)) goto exit; return_value = _elementtree_Element_get_impl(self, key, default_value); @@ -298,19 +298,19 @@ PyDoc_STRVAR(_elementtree_Element_iter__ "\n"); #define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \ - {"iter", (PyCFunction)_elementtree_Element_iter, METH_VARARGS|METH_KEYWORDS, _elementtree_Element_iter__doc__}, + {"iter", (PyCFunction)_elementtree_Element_iter, METH_FASTCALL, _elementtree_Element_iter__doc__}, static PyObject * _elementtree_Element_iter_impl(ElementObject *self, PyObject *tag); static PyObject * -_elementtree_Element_iter(ElementObject *self, PyObject *args, PyObject *kwargs) +_elementtree_Element_iter(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"tag", NULL}; PyObject *tag = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:iter", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:iter", _keywords, &tag)) goto exit; return_value = _elementtree_Element_iter_impl(self, tag); @@ -342,22 +342,24 @@ PyDoc_STRVAR(_elementtree_Element_insert "\n"); #define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \ - {"insert", (PyCFunction)_elementtree_Element_insert, METH_VARARGS, _elementtree_Element_insert__doc__}, + {"insert", (PyCFunction)_elementtree_Element_insert, METH_FASTCALL, _elementtree_Element_insert__doc__}, static PyObject * _elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index, PyObject *subelement); static PyObject * -_elementtree_Element_insert(ElementObject *self, PyObject *args) +_elementtree_Element_insert(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t index; PyObject *subelement; - if (!PyArg_ParseTuple(args, "nO!:insert", + if (!PyArg_ParseStack(stack, nargs, "nO!:insert", &index, &Element_Type, &subelement)) goto exit; + if (!_PyArg_NoKeywords("insert()", kwargs)) + goto exit; return_value = _elementtree_Element_insert_impl(self, index, subelement); exit: @@ -404,23 +406,25 @@ PyDoc_STRVAR(_elementtree_Element_makeel "\n"); #define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \ - {"makeelement", (PyCFunction)_elementtree_Element_makeelement, METH_VARARGS, _elementtree_Element_makeelement__doc__}, + {"makeelement", (PyCFunction)_elementtree_Element_makeelement, METH_FASTCALL, _elementtree_Element_makeelement__doc__}, static PyObject * _elementtree_Element_makeelement_impl(ElementObject *self, PyObject *tag, PyObject *attrib); static PyObject * -_elementtree_Element_makeelement(ElementObject *self, PyObject *args) +_elementtree_Element_makeelement(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *tag; PyObject *attrib; - if (!PyArg_UnpackTuple(args, "makeelement", + if (!PyArg_UnpackStack(stack, nargs, "makeelement", 2, 2, &tag, &attrib)) goto exit; + if (!_PyArg_NoKeywords("makeelement", kwargs)) + goto exit; return_value = _elementtree_Element_makeelement_impl(self, tag, attrib); exit: @@ -458,23 +462,25 @@ PyDoc_STRVAR(_elementtree_Element_set__d "\n"); #define _ELEMENTTREE_ELEMENT_SET_METHODDEF \ - {"set", (PyCFunction)_elementtree_Element_set, METH_VARARGS, _elementtree_Element_set__doc__}, + {"set", (PyCFunction)_elementtree_Element_set, METH_FASTCALL, _elementtree_Element_set__doc__}, static PyObject * _elementtree_Element_set_impl(ElementObject *self, PyObject *key, PyObject *value); static PyObject * -_elementtree_Element_set(ElementObject *self, PyObject *args) +_elementtree_Element_set(ElementObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *key; PyObject *value; - if (!PyArg_UnpackTuple(args, "set", + if (!PyArg_UnpackStack(stack, nargs, "set", 2, 2, &key, &value)) goto exit; + if (!_PyArg_NoKeywords("set", kwargs)) + goto exit; return_value = _elementtree_Element_set_impl(self, key, value); exit: @@ -540,23 +546,25 @@ PyDoc_STRVAR(_elementtree_TreeBuilder_st "\n"); #define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \ - {"start", (PyCFunction)_elementtree_TreeBuilder_start, METH_VARARGS, _elementtree_TreeBuilder_start__doc__}, + {"start", (PyCFunction)_elementtree_TreeBuilder_start, METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, static PyObject * _elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag, PyObject *attrs); static PyObject * -_elementtree_TreeBuilder_start(TreeBuilderObject *self, PyObject *args) +_elementtree_TreeBuilder_start(TreeBuilderObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *tag; PyObject *attrs = Py_None; - if (!PyArg_UnpackTuple(args, "start", + if (!PyArg_UnpackStack(stack, nargs, "start", 1, 2, &tag, &attrs)) goto exit; + if (!_PyArg_NoKeywords("start", kwargs)) + goto exit; return_value = _elementtree_TreeBuilder_start_impl(self, tag, attrs); exit: @@ -624,24 +632,26 @@ PyDoc_STRVAR(_elementtree_XMLParser_doct "\n"); #define _ELEMENTTREE_XMLPARSER_DOCTYPE_METHODDEF \ - {"doctype", (PyCFunction)_elementtree_XMLParser_doctype, METH_VARARGS, _elementtree_XMLParser_doctype__doc__}, + {"doctype", (PyCFunction)_elementtree_XMLParser_doctype, METH_FASTCALL, _elementtree_XMLParser_doctype__doc__}, static PyObject * _elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name, PyObject *pubid, PyObject *system); static PyObject * -_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject *args) +_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *name; PyObject *pubid; PyObject *system; - if (!PyArg_UnpackTuple(args, "doctype", + if (!PyArg_UnpackStack(stack, nargs, "doctype", 3, 3, &name, &pubid, &system)) goto exit; + if (!_PyArg_NoKeywords("doctype", kwargs)) + goto exit; return_value = _elementtree_XMLParser_doctype_impl(self, name, pubid, system); exit: @@ -654,7 +664,7 @@ PyDoc_STRVAR(_elementtree_XMLParser__set "\n"); #define _ELEMENTTREE_XMLPARSER__SETEVENTS_METHODDEF \ - {"_setevents", (PyCFunction)_elementtree_XMLParser__setevents, METH_VARARGS, _elementtree_XMLParser__setevents__doc__}, + {"_setevents", (PyCFunction)_elementtree_XMLParser__setevents, METH_FASTCALL, _elementtree_XMLParser__setevents__doc__}, static PyObject * _elementtree_XMLParser__setevents_impl(XMLParserObject *self, @@ -662,19 +672,21 @@ static PyObject * PyObject *events_to_report); static PyObject * -_elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *args) +_elementtree_XMLParser__setevents(XMLParserObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *events_queue; PyObject *events_to_report = Py_None; - if (!PyArg_UnpackTuple(args, "_setevents", + if (!PyArg_UnpackStack(stack, nargs, "_setevents", 1, 2, &events_queue, &events_to_report)) goto exit; + if (!_PyArg_NoKeywords("_setevents", kwargs)) + goto exit; return_value = _elementtree_XMLParser__setevents_impl(self, events_queue, events_to_report); exit: return return_value; } -/*[clinic end generated code: output=19d94e2d2726d3aa input=a9049054013a1b77]*/ +/*[clinic end generated code: output=908b6e50b250c9cd input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_gdbmmodule.c.h --- a/Modules/clinic/_gdbmmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_gdbmmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -9,22 +9,24 @@ PyDoc_STRVAR(_gdbm_gdbm_get__doc__, "Get the value for key, or default if not present."); #define _GDBM_GDBM_GET_METHODDEF \ - {"get", (PyCFunction)_gdbm_gdbm_get, METH_VARARGS, _gdbm_gdbm_get__doc__}, + {"get", (PyCFunction)_gdbm_gdbm_get, METH_FASTCALL, _gdbm_gdbm_get__doc__}, static PyObject * _gdbm_gdbm_get_impl(dbmobject *self, PyObject *key, PyObject *default_value); static PyObject * -_gdbm_gdbm_get(dbmobject *self, PyObject *args) +_gdbm_gdbm_get(dbmobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *key; PyObject *default_value = Py_None; - if (!PyArg_UnpackTuple(args, "get", + if (!PyArg_UnpackStack(stack, nargs, "get", 1, 2, &key, &default_value)) goto exit; + if (!_PyArg_NoKeywords("get", kwargs)) + goto exit; return_value = _gdbm_gdbm_get_impl(self, key, default_value); exit: @@ -38,23 +40,25 @@ PyDoc_STRVAR(_gdbm_gdbm_setdefault__doc_ "Get value for key, or set it to default and return default if not present."); #define _GDBM_GDBM_SETDEFAULT_METHODDEF \ - {"setdefault", (PyCFunction)_gdbm_gdbm_setdefault, METH_VARARGS, _gdbm_gdbm_setdefault__doc__}, + {"setdefault", (PyCFunction)_gdbm_gdbm_setdefault, METH_FASTCALL, _gdbm_gdbm_setdefault__doc__}, static PyObject * _gdbm_gdbm_setdefault_impl(dbmobject *self, PyObject *key, PyObject *default_value); static PyObject * -_gdbm_gdbm_setdefault(dbmobject *self, PyObject *args) +_gdbm_gdbm_setdefault(dbmobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *key; PyObject *default_value = Py_None; - if (!PyArg_UnpackTuple(args, "setdefault", + if (!PyArg_UnpackStack(stack, nargs, "setdefault", 1, 2, &key, &default_value)) goto exit; + if (!_PyArg_NoKeywords("setdefault", kwargs)) + goto exit; return_value = _gdbm_gdbm_setdefault_impl(self, key, default_value); exit: @@ -228,26 +232,28 @@ PyDoc_STRVAR(dbmopen__doc__, "when the database has to be created. It defaults to octal 0o666."); #define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__}, + {"open", (PyCFunction)dbmopen, METH_FASTCALL, dbmopen__doc__}, static PyObject * dbmopen_impl(PyModuleDef *module, const char *name, const char *flags, int mode); static PyObject * -dbmopen(PyModuleDef *module, PyObject *args) +dbmopen(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *name; const char *flags = "r"; int mode = 438; - if (!PyArg_ParseTuple(args, "s|si:open", + if (!PyArg_ParseStack(stack, nargs, "s|si:open", &name, &flags, &mode)) goto exit; + if (!_PyArg_NoKeywords("open()", kwargs)) + goto exit; return_value = dbmopen_impl(module, name, flags, mode); exit: return return_value; } -/*[clinic end generated code: output=d3d8d871bcccb68a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d419511f99ae5e3f input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_lzmamodule.c.h --- a/Modules/clinic/_lzmamodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_lzmamodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -79,21 +79,21 @@ PyDoc_STRVAR(_lzma_LZMADecompressor_deco "the unused_data attribute."); #define _LZMA_LZMADECOMPRESSOR_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)_lzma_LZMADecompressor_decompress, METH_VARARGS|METH_KEYWORDS, _lzma_LZMADecompressor_decompress__doc__}, + {"decompress", (PyCFunction)_lzma_LZMADecompressor_decompress, METH_FASTCALL, _lzma_LZMADecompressor_decompress__doc__}, static PyObject * _lzma_LZMADecompressor_decompress_impl(Decompressor *self, Py_buffer *data, Py_ssize_t max_length); static PyObject * -_lzma_LZMADecompressor_decompress(Decompressor *self, PyObject *args, PyObject *kwargs) +_lzma_LZMADecompressor_decompress(Decompressor *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "max_length", NULL}; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|n:decompress", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|n:decompress", _keywords, &data, &max_length)) goto exit; return_value = _lzma_LZMADecompressor_decompress_impl(self, &data, max_length); @@ -220,22 +220,24 @@ PyDoc_STRVAR(_lzma__decode_filter_proper "The result does not include the filter ID itself, only the options."); #define _LZMA__DECODE_FILTER_PROPERTIES_METHODDEF \ - {"_decode_filter_properties", (PyCFunction)_lzma__decode_filter_properties, METH_VARARGS, _lzma__decode_filter_properties__doc__}, + {"_decode_filter_properties", (PyCFunction)_lzma__decode_filter_properties, METH_FASTCALL, _lzma__decode_filter_properties__doc__}, static PyObject * _lzma__decode_filter_properties_impl(PyModuleDef *module, lzma_vli filter_id, Py_buffer *encoded_props); static PyObject * -_lzma__decode_filter_properties(PyModuleDef *module, PyObject *args) +_lzma__decode_filter_properties(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; lzma_vli filter_id; Py_buffer encoded_props = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "O&y*:_decode_filter_properties", + if (!PyArg_ParseStack(stack, nargs, "O&y*:_decode_filter_properties", lzma_vli_converter, &filter_id, &encoded_props)) goto exit; + if (!_PyArg_NoKeywords("_decode_filter_properties()", kwargs)) + goto exit; return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props); exit: @@ -245,4 +247,4 @@ exit: return return_value; } -/*[clinic end generated code: output=2d3e0842be3d3fe1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=538607ebc32bcaa0 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_opcode.c.h --- a/Modules/clinic/_opcode.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_opcode.c.h Thu May 19 13:47:42 2016 +0200 @@ -9,22 +9,24 @@ PyDoc_STRVAR(_opcode_stack_effect__doc__ "Compute the stack effect of the opcode."); #define _OPCODE_STACK_EFFECT_METHODDEF \ - {"stack_effect", (PyCFunction)_opcode_stack_effect, METH_VARARGS, _opcode_stack_effect__doc__}, + {"stack_effect", (PyCFunction)_opcode_stack_effect, METH_FASTCALL, _opcode_stack_effect__doc__}, static int _opcode_stack_effect_impl(PyModuleDef *module, int opcode, PyObject *oparg); static PyObject * -_opcode_stack_effect(PyModuleDef *module, PyObject *args) +_opcode_stack_effect(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int opcode; PyObject *oparg = Py_None; int _return_value; - if (!PyArg_ParseTuple(args, "i|O:stack_effect", + if (!PyArg_ParseStack(stack, nargs, "i|O:stack_effect", &opcode, &oparg)) goto exit; + if (!_PyArg_NoKeywords("stack_effect()", kwargs)) + goto exit; _return_value = _opcode_stack_effect_impl(module, opcode, oparg); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -33,4 +35,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=8ee7cb735705e8b3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f60608bff590b306 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_pickle.c.h --- a/Modules/clinic/_pickle.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_pickle.c.h Thu May 19 13:47:42 2016 +0200 @@ -196,7 +196,7 @@ PyDoc_STRVAR(_pickle_Unpickler_find_clas "needed. Both arguments passed are str objects."); #define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF \ - {"find_class", (PyCFunction)_pickle_Unpickler_find_class, METH_VARARGS, _pickle_Unpickler_find_class__doc__}, + {"find_class", (PyCFunction)_pickle_Unpickler_find_class, METH_FASTCALL, _pickle_Unpickler_find_class__doc__}, static PyObject * _pickle_Unpickler_find_class_impl(UnpicklerObject *self, @@ -204,16 +204,18 @@ static PyObject * PyObject *global_name); static PyObject * -_pickle_Unpickler_find_class(UnpicklerObject *self, PyObject *args) +_pickle_Unpickler_find_class(UnpicklerObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *module_name; PyObject *global_name; - if (!PyArg_UnpackTuple(args, "find_class", + if (!PyArg_UnpackStack(stack, nargs, "find_class", 2, 2, &module_name, &global_name)) goto exit; + if (!_PyArg_NoKeywords("find_class", kwargs)) + goto exit; return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name); exit: @@ -377,14 +379,14 @@ PyDoc_STRVAR(_pickle_dump__doc__, "2, so that the pickle data stream is readable with Python 2."); #define _PICKLE_DUMP_METHODDEF \ - {"dump", (PyCFunction)_pickle_dump, METH_VARARGS|METH_KEYWORDS, _pickle_dump__doc__}, + {"dump", (PyCFunction)_pickle_dump, METH_FASTCALL, _pickle_dump__doc__}, static PyObject * _pickle_dump_impl(PyModuleDef *module, PyObject *obj, PyObject *file, PyObject *protocol, int fix_imports); static PyObject * -_pickle_dump(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_pickle_dump(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"obj", "file", "protocol", "fix_imports", NULL}; @@ -393,7 +395,7 @@ static PyObject * PyObject *protocol = NULL; int fix_imports = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O$p:dump", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "OO|O$p:dump", _keywords, &obj, &file, &protocol, &fix_imports)) goto exit; return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports); @@ -421,14 +423,14 @@ PyDoc_STRVAR(_pickle_dumps__doc__, "Python 2, so that the pickle data stream is readable with Python 2."); #define _PICKLE_DUMPS_METHODDEF \ - {"dumps", (PyCFunction)_pickle_dumps, METH_VARARGS|METH_KEYWORDS, _pickle_dumps__doc__}, + {"dumps", (PyCFunction)_pickle_dumps, METH_FASTCALL, _pickle_dumps__doc__}, static PyObject * _pickle_dumps_impl(PyModuleDef *module, PyObject *obj, PyObject *protocol, int fix_imports); static PyObject * -_pickle_dumps(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_pickle_dumps(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"obj", "protocol", "fix_imports", NULL}; @@ -436,7 +438,7 @@ static PyObject * PyObject *protocol = NULL; int fix_imports = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O$p:dumps", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|O$p:dumps", _keywords, &obj, &protocol, &fix_imports)) goto exit; return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports); @@ -475,14 +477,14 @@ PyDoc_STRVAR(_pickle_load__doc__, "string instances as bytes objects."); #define _PICKLE_LOAD_METHODDEF \ - {"load", (PyCFunction)_pickle_load, METH_VARARGS|METH_KEYWORDS, _pickle_load__doc__}, + {"load", (PyCFunction)_pickle_load, METH_FASTCALL, _pickle_load__doc__}, static PyObject * _pickle_load_impl(PyModuleDef *module, PyObject *file, int fix_imports, const char *encoding, const char *errors); static PyObject * -_pickle_load(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_pickle_load(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"file", "fix_imports", "encoding", "errors", NULL}; @@ -491,7 +493,7 @@ static PyObject * const char *encoding = "ASCII"; const char *errors = "strict"; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|$pss:load", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|$pss:load", _keywords, &file, &fix_imports, &encoding, &errors)) goto exit; return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors); @@ -521,14 +523,14 @@ PyDoc_STRVAR(_pickle_loads__doc__, "string instances as bytes objects."); #define _PICKLE_LOADS_METHODDEF \ - {"loads", (PyCFunction)_pickle_loads, METH_VARARGS|METH_KEYWORDS, _pickle_loads__doc__}, + {"loads", (PyCFunction)_pickle_loads, METH_FASTCALL, _pickle_loads__doc__}, static PyObject * _pickle_loads_impl(PyModuleDef *module, PyObject *data, int fix_imports, const char *encoding, const char *errors); static PyObject * -_pickle_loads(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_pickle_loads(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "fix_imports", "encoding", "errors", NULL}; @@ -537,7 +539,7 @@ static PyObject * const char *encoding = "ASCII"; const char *errors = "strict"; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|$pss:loads", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|$pss:loads", _keywords, &data, &fix_imports, &encoding, &errors)) goto exit; return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors); @@ -545,4 +547,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=aecd61660d1cf31d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=198a78c7c20492ac input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_sre.c.h --- a/Modules/clinic/_sre.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_sre.c.h Thu May 19 13:47:42 2016 +0200 @@ -34,22 +34,24 @@ PyDoc_STRVAR(_sre_getlower__doc__, "\n"); #define _SRE_GETLOWER_METHODDEF \ - {"getlower", (PyCFunction)_sre_getlower, METH_VARARGS, _sre_getlower__doc__}, + {"getlower", (PyCFunction)_sre_getlower, METH_FASTCALL, _sre_getlower__doc__}, static int _sre_getlower_impl(PyModuleDef *module, int character, int flags); static PyObject * -_sre_getlower(PyModuleDef *module, PyObject *args) +_sre_getlower(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int character; int flags; int _return_value; - if (!PyArg_ParseTuple(args, "ii:getlower", + if (!PyArg_ParseStack(stack, nargs, "ii:getlower", &character, &flags)) goto exit; + if (!_PyArg_NoKeywords("getlower()", kwargs)) + goto exit; _return_value = _sre_getlower_impl(module, character, flags); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -66,7 +68,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_match__doc "Matches zero or more characters at the beginning of the string."); #define _SRE_SRE_PATTERN_MATCH_METHODDEF \ - {"match", (PyCFunction)_sre_SRE_Pattern_match, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__}, + {"match", (PyCFunction)_sre_SRE_Pattern_match, METH_FASTCALL, _sre_SRE_Pattern_match__doc__}, static PyObject * _sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string, @@ -74,7 +76,7 @@ static PyObject * PyObject *pattern); static PyObject * -_sre_SRE_Pattern_match(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_match(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "pos", "endpos", "pattern", NULL}; @@ -83,7 +85,7 @@ static PyObject * Py_ssize_t endpos = PY_SSIZE_T_MAX; PyObject *pattern = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:match", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|Onn$O:match", _keywords, &string, &pos, &endpos, &pattern)) goto exit; return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos, pattern); @@ -100,7 +102,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch_ "Matches against all of the string"); #define _SRE_SRE_PATTERN_FULLMATCH_METHODDEF \ - {"fullmatch", (PyCFunction)_sre_SRE_Pattern_fullmatch, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__}, + {"fullmatch", (PyCFunction)_sre_SRE_Pattern_fullmatch, METH_FASTCALL, _sre_SRE_Pattern_fullmatch__doc__}, static PyObject * _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string, @@ -108,7 +110,7 @@ static PyObject * PyObject *pattern); static PyObject * -_sre_SRE_Pattern_fullmatch(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_fullmatch(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "pos", "endpos", "pattern", NULL}; @@ -117,7 +119,7 @@ static PyObject * Py_ssize_t endpos = PY_SSIZE_T_MAX; PyObject *pattern = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:fullmatch", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|Onn$O:fullmatch", _keywords, &string, &pos, &endpos, &pattern)) goto exit; return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos, pattern); @@ -136,7 +138,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_search__do "Return None if no position in the string matches."); #define _SRE_SRE_PATTERN_SEARCH_METHODDEF \ - {"search", (PyCFunction)_sre_SRE_Pattern_search, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__}, + {"search", (PyCFunction)_sre_SRE_Pattern_search, METH_FASTCALL, _sre_SRE_Pattern_search__doc__}, static PyObject * _sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string, @@ -144,7 +146,7 @@ static PyObject * PyObject *pattern); static PyObject * -_sre_SRE_Pattern_search(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_search(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "pos", "endpos", "pattern", NULL}; @@ -153,7 +155,7 @@ static PyObject * Py_ssize_t endpos = PY_SSIZE_T_MAX; PyObject *pattern = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:search", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|Onn$O:search", _keywords, &string, &pos, &endpos, &pattern)) goto exit; return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos, pattern); @@ -170,7 +172,7 @@ PyDoc_STRVAR(_sre_SRE_Pattern_findall__d "Return a list of all non-overlapping matches of pattern in string."); #define _SRE_SRE_PATTERN_FINDALL_METHODDEF \ - {"findall", (PyCFunction)_sre_SRE_Pattern_findall, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__}, + {"findall", (PyCFunction)_sre_SRE_Pattern_findall, METH_FASTCALL, _sre_SRE_Pattern_findall__doc__}, static PyObject * _sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string, @@ -178,7 +180,7 @@ static PyObject * PyObject *source); static PyObject * -_sre_SRE_Pattern_findall(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_findall(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "pos", "endpos", "source", NULL}; @@ -187,7 +189,7 @@ static PyObject * Py_ssize_t endpos = PY_SSIZE_T_MAX; PyObject *source = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:findall", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|Onn$O:findall", _keywords, &string, &pos, &endpos, &source)) goto exit; return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos, source); @@ -205,14 +207,14 @@ PyDoc_STRVAR(_sre_SRE_Pattern_finditer__ "For each match, the iterator returns a match object."); #define _SRE_SRE_PATTERN_FINDITER_METHODDEF \ - {"finditer", (PyCFunction)_sre_SRE_Pattern_finditer, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__}, + {"finditer", (PyCFunction)_sre_SRE_Pattern_finditer, METH_FASTCALL, _sre_SRE_Pattern_finditer__doc__}, static PyObject * _sre_SRE_Pattern_finditer_impl(PatternObject *self, PyObject *string, Py_ssize_t pos, Py_ssize_t endpos); static PyObject * -_sre_SRE_Pattern_finditer(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_finditer(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "pos", "endpos", NULL}; @@ -220,7 +222,7 @@ static PyObject * Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|nn:finditer", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|nn:finditer", _keywords, &string, &pos, &endpos)) goto exit; return_value = _sre_SRE_Pattern_finditer_impl(self, string, pos, endpos); @@ -235,14 +237,14 @@ PyDoc_STRVAR(_sre_SRE_Pattern_scanner__d "\n"); #define _SRE_SRE_PATTERN_SCANNER_METHODDEF \ - {"scanner", (PyCFunction)_sre_SRE_Pattern_scanner, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__}, + {"scanner", (PyCFunction)_sre_SRE_Pattern_scanner, METH_FASTCALL, _sre_SRE_Pattern_scanner__doc__}, static PyObject * _sre_SRE_Pattern_scanner_impl(PatternObject *self, PyObject *string, Py_ssize_t pos, Py_ssize_t endpos); static PyObject * -_sre_SRE_Pattern_scanner(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_scanner(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "pos", "endpos", NULL}; @@ -250,7 +252,7 @@ static PyObject * Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|nn:scanner", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|nn:scanner", _keywords, &string, &pos, &endpos)) goto exit; return_value = _sre_SRE_Pattern_scanner_impl(self, string, pos, endpos); @@ -266,14 +268,14 @@ PyDoc_STRVAR(_sre_SRE_Pattern_split__doc "Split string by the occurrences of pattern."); #define _SRE_SRE_PATTERN_SPLIT_METHODDEF \ - {"split", (PyCFunction)_sre_SRE_Pattern_split, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__}, + {"split", (PyCFunction)_sre_SRE_Pattern_split, METH_FASTCALL, _sre_SRE_Pattern_split__doc__}, static PyObject * _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, Py_ssize_t maxsplit, PyObject *source); static PyObject * -_sre_SRE_Pattern_split(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_split(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", "maxsplit", "source", NULL}; @@ -281,7 +283,7 @@ static PyObject * Py_ssize_t maxsplit = 0; PyObject *source = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On$O:split", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|On$O:split", _keywords, &string, &maxsplit, &source)) goto exit; return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit, source); @@ -297,14 +299,14 @@ PyDoc_STRVAR(_sre_SRE_Pattern_sub__doc__ "Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl."); #define _SRE_SRE_PATTERN_SUB_METHODDEF \ - {"sub", (PyCFunction)_sre_SRE_Pattern_sub, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__}, + {"sub", (PyCFunction)_sre_SRE_Pattern_sub, METH_FASTCALL, _sre_SRE_Pattern_sub__doc__}, static PyObject * _sre_SRE_Pattern_sub_impl(PatternObject *self, PyObject *repl, PyObject *string, Py_ssize_t count); static PyObject * -_sre_SRE_Pattern_sub(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_sub(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"repl", "string", "count", NULL}; @@ -312,7 +314,7 @@ static PyObject * PyObject *string; Py_ssize_t count = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|n:sub", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "OO|n:sub", _keywords, &repl, &string, &count)) goto exit; return_value = _sre_SRE_Pattern_sub_impl(self, repl, string, count); @@ -328,14 +330,14 @@ PyDoc_STRVAR(_sre_SRE_Pattern_subn__doc_ "Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl."); #define _SRE_SRE_PATTERN_SUBN_METHODDEF \ - {"subn", (PyCFunction)_sre_SRE_Pattern_subn, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__}, + {"subn", (PyCFunction)_sre_SRE_Pattern_subn, METH_FASTCALL, _sre_SRE_Pattern_subn__doc__}, static PyObject * _sre_SRE_Pattern_subn_impl(PatternObject *self, PyObject *repl, PyObject *string, Py_ssize_t count); static PyObject * -_sre_SRE_Pattern_subn(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern_subn(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"repl", "string", "count", NULL}; @@ -343,7 +345,7 @@ static PyObject * PyObject *string; Py_ssize_t count = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|n:subn", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "OO|n:subn", _keywords, &repl, &string, &count)) goto exit; return_value = _sre_SRE_Pattern_subn_impl(self, repl, string, count); @@ -375,19 +377,19 @@ PyDoc_STRVAR(_sre_SRE_Pattern___deepcopy "\n"); #define _SRE_SRE_PATTERN___DEEPCOPY___METHODDEF \ - {"__deepcopy__", (PyCFunction)_sre_SRE_Pattern___deepcopy__, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Pattern___deepcopy____doc__}, + {"__deepcopy__", (PyCFunction)_sre_SRE_Pattern___deepcopy__, METH_FASTCALL, _sre_SRE_Pattern___deepcopy____doc__}, static PyObject * _sre_SRE_Pattern___deepcopy___impl(PatternObject *self, PyObject *memo); static PyObject * -_sre_SRE_Pattern___deepcopy__(PatternObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Pattern___deepcopy__(PatternObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"memo", NULL}; PyObject *memo; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:__deepcopy__", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O:__deepcopy__", _keywords, &memo)) goto exit; return_value = _sre_SRE_Pattern___deepcopy___impl(self, memo); @@ -403,7 +405,7 @@ PyDoc_STRVAR(_sre_compile__doc__, "\n"); #define _SRE_COMPILE_METHODDEF \ - {"compile", (PyCFunction)_sre_compile, METH_VARARGS|METH_KEYWORDS, _sre_compile__doc__}, + {"compile", (PyCFunction)_sre_compile, METH_FASTCALL, _sre_compile__doc__}, static PyObject * _sre_compile_impl(PyModuleDef *module, PyObject *pattern, int flags, @@ -411,7 +413,7 @@ static PyObject * PyObject *indexgroup); static PyObject * -_sre_compile(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_sre_compile(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL}; @@ -422,7 +424,7 @@ static PyObject * PyObject *groupindex; PyObject *indexgroup; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO!nOO:compile", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "OiO!nOO:compile", _keywords, &pattern, &flags, &PyList_Type, &code, &groups, &groupindex, &indexgroup)) goto exit; return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup); @@ -438,19 +440,19 @@ PyDoc_STRVAR(_sre_SRE_Match_expand__doc_ "Return the string obtained by doing backslash substitution on the string template, as done by the sub() method."); #define _SRE_SRE_MATCH_EXPAND_METHODDEF \ - {"expand", (PyCFunction)_sre_SRE_Match_expand, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Match_expand__doc__}, + {"expand", (PyCFunction)_sre_SRE_Match_expand, METH_FASTCALL, _sre_SRE_Match_expand__doc__}, static PyObject * _sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template); static PyObject * -_sre_SRE_Match_expand(MatchObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Match_expand(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"template", NULL}; PyObject *template; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:expand", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O:expand", _keywords, &template)) goto exit; return_value = _sre_SRE_Match_expand_impl(self, template); @@ -469,19 +471,19 @@ PyDoc_STRVAR(_sre_SRE_Match_groups__doc_ " Is used for groups that did not participate in the match."); #define _SRE_SRE_MATCH_GROUPS_METHODDEF \ - {"groups", (PyCFunction)_sre_SRE_Match_groups, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Match_groups__doc__}, + {"groups", (PyCFunction)_sre_SRE_Match_groups, METH_FASTCALL, _sre_SRE_Match_groups__doc__}, static PyObject * _sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value); static PyObject * -_sre_SRE_Match_groups(MatchObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Match_groups(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"default", NULL}; PyObject *default_value = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:groups", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:groups", _keywords, &default_value)) goto exit; return_value = _sre_SRE_Match_groups_impl(self, default_value); @@ -500,19 +502,19 @@ PyDoc_STRVAR(_sre_SRE_Match_groupdict__d " Is used for groups that did not participate in the match."); #define _SRE_SRE_MATCH_GROUPDICT_METHODDEF \ - {"groupdict", (PyCFunction)_sre_SRE_Match_groupdict, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__}, + {"groupdict", (PyCFunction)_sre_SRE_Match_groupdict, METH_FASTCALL, _sre_SRE_Match_groupdict__doc__}, static PyObject * _sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value); static PyObject * -_sre_SRE_Match_groupdict(MatchObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Match_groupdict(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"default", NULL}; PyObject *default_value = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:groupdict", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:groupdict", _keywords, &default_value)) goto exit; return_value = _sre_SRE_Match_groupdict_impl(self, default_value); @@ -528,22 +530,24 @@ PyDoc_STRVAR(_sre_SRE_Match_start__doc__ "Return index of the start of the substring matched by group."); #define _SRE_SRE_MATCH_START_METHODDEF \ - {"start", (PyCFunction)_sre_SRE_Match_start, METH_VARARGS, _sre_SRE_Match_start__doc__}, + {"start", (PyCFunction)_sre_SRE_Match_start, METH_FASTCALL, _sre_SRE_Match_start__doc__}, static Py_ssize_t _sre_SRE_Match_start_impl(MatchObject *self, PyObject *group); static PyObject * -_sre_SRE_Match_start(MatchObject *self, PyObject *args) +_sre_SRE_Match_start(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *group = NULL; Py_ssize_t _return_value; - if (!PyArg_UnpackTuple(args, "start", + if (!PyArg_UnpackStack(stack, nargs, "start", 0, 1, &group)) goto exit; + if (!_PyArg_NoKeywords("start", kwargs)) + goto exit; _return_value = _sre_SRE_Match_start_impl(self, group); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -560,22 +564,24 @@ PyDoc_STRVAR(_sre_SRE_Match_end__doc__, "Return index of the end of the substring matched by group."); #define _SRE_SRE_MATCH_END_METHODDEF \ - {"end", (PyCFunction)_sre_SRE_Match_end, METH_VARARGS, _sre_SRE_Match_end__doc__}, + {"end", (PyCFunction)_sre_SRE_Match_end, METH_FASTCALL, _sre_SRE_Match_end__doc__}, static Py_ssize_t _sre_SRE_Match_end_impl(MatchObject *self, PyObject *group); static PyObject * -_sre_SRE_Match_end(MatchObject *self, PyObject *args) +_sre_SRE_Match_end(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *group = NULL; Py_ssize_t _return_value; - if (!PyArg_UnpackTuple(args, "end", + if (!PyArg_UnpackStack(stack, nargs, "end", 0, 1, &group)) goto exit; + if (!_PyArg_NoKeywords("end", kwargs)) + goto exit; _return_value = _sre_SRE_Match_end_impl(self, group); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -592,21 +598,23 @@ PyDoc_STRVAR(_sre_SRE_Match_span__doc__, "For MatchObject m, return the 2-tuple (m.start(group), m.end(group))."); #define _SRE_SRE_MATCH_SPAN_METHODDEF \ - {"span", (PyCFunction)_sre_SRE_Match_span, METH_VARARGS, _sre_SRE_Match_span__doc__}, + {"span", (PyCFunction)_sre_SRE_Match_span, METH_FASTCALL, _sre_SRE_Match_span__doc__}, static PyObject * _sre_SRE_Match_span_impl(MatchObject *self, PyObject *group); static PyObject * -_sre_SRE_Match_span(MatchObject *self, PyObject *args) +_sre_SRE_Match_span(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *group = NULL; - if (!PyArg_UnpackTuple(args, "span", + if (!PyArg_UnpackStack(stack, nargs, "span", 0, 1, &group)) goto exit; + if (!_PyArg_NoKeywords("span", kwargs)) + goto exit; return_value = _sre_SRE_Match_span_impl(self, group); exit: @@ -636,19 +644,19 @@ PyDoc_STRVAR(_sre_SRE_Match___deepcopy__ "\n"); #define _SRE_SRE_MATCH___DEEPCOPY___METHODDEF \ - {"__deepcopy__", (PyCFunction)_sre_SRE_Match___deepcopy__, METH_VARARGS|METH_KEYWORDS, _sre_SRE_Match___deepcopy____doc__}, + {"__deepcopy__", (PyCFunction)_sre_SRE_Match___deepcopy__, METH_FASTCALL, _sre_SRE_Match___deepcopy____doc__}, static PyObject * _sre_SRE_Match___deepcopy___impl(MatchObject *self, PyObject *memo); static PyObject * -_sre_SRE_Match___deepcopy__(MatchObject *self, PyObject *args, PyObject *kwargs) +_sre_SRE_Match___deepcopy__(MatchObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"memo", NULL}; PyObject *memo; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:__deepcopy__", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O:__deepcopy__", _keywords, &memo)) goto exit; return_value = _sre_SRE_Match___deepcopy___impl(self, memo); @@ -690,4 +698,4 @@ static PyObject * { return _sre_SRE_Scanner_search_impl(self); } -/*[clinic end generated code: output=d1d73ab2c5008bd4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=482885c5771cfb4a input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_ssl.c.h --- a/Modules/clinic/_ssl.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_ssl.c.h Thu May 19 13:47:42 2016 +0200 @@ -59,20 +59,22 @@ PyDoc_STRVAR(_ssl__SSLSocket_peer_certif "return the certificate even if it wasn\'t validated."); #define _SSL__SSLSOCKET_PEER_CERTIFICATE_METHODDEF \ - {"peer_certificate", (PyCFunction)_ssl__SSLSocket_peer_certificate, METH_VARARGS, _ssl__SSLSocket_peer_certificate__doc__}, + {"peer_certificate", (PyCFunction)_ssl__SSLSocket_peer_certificate, METH_FASTCALL, _ssl__SSLSocket_peer_certificate__doc__}, static PyObject * _ssl__SSLSocket_peer_certificate_impl(PySSLSocket *self, int binary_mode); static PyObject * -_ssl__SSLSocket_peer_certificate(PySSLSocket *self, PyObject *args) +_ssl__SSLSocket_peer_certificate(PySSLSocket *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int binary_mode = 0; - if (!PyArg_ParseTuple(args, "|p:peer_certificate", + if (!PyArg_ParseStack(stack, nargs, "|p:peer_certificate", &binary_mode)) goto exit; + if (!_PyArg_NoKeywords("peer_certificate()", kwargs)) + goto exit; return_value = _ssl__SSLSocket_peer_certificate_impl(self, binary_mode); exit: @@ -434,14 +436,14 @@ PyDoc_STRVAR(_ssl__SSLContext_load_cert_ "\n"); #define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF \ - {"load_cert_chain", (PyCFunction)_ssl__SSLContext_load_cert_chain, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__}, + {"load_cert_chain", (PyCFunction)_ssl__SSLContext_load_cert_chain, METH_FASTCALL, _ssl__SSLContext_load_cert_chain__doc__}, static PyObject * _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile, PyObject *keyfile, PyObject *password); static PyObject * -_ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject *args, PyObject *kwargs) +_ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"certfile", "keyfile", "password", NULL}; @@ -449,7 +451,7 @@ static PyObject * PyObject *keyfile = NULL; PyObject *password = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:load_cert_chain", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O|OO:load_cert_chain", _keywords, &certfile, &keyfile, &password)) goto exit; return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password); @@ -464,7 +466,7 @@ PyDoc_STRVAR(_ssl__SSLContext_load_verif "\n"); #define _SSL__SSLCONTEXT_LOAD_VERIFY_LOCATIONS_METHODDEF \ - {"load_verify_locations", (PyCFunction)_ssl__SSLContext_load_verify_locations, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__}, + {"load_verify_locations", (PyCFunction)_ssl__SSLContext_load_verify_locations, METH_FASTCALL, _ssl__SSLContext_load_verify_locations__doc__}, static PyObject * _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self, @@ -473,7 +475,7 @@ static PyObject * PyObject *cadata); static PyObject * -_ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject *args, PyObject *kwargs) +_ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"cafile", "capath", "cadata", NULL}; @@ -481,7 +483,7 @@ static PyObject * PyObject *capath = NULL; PyObject *cadata = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO:load_verify_locations", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|OOO:load_verify_locations", _keywords, &cafile, &capath, &cadata)) goto exit; return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata); @@ -504,14 +506,14 @@ PyDoc_STRVAR(_ssl__SSLContext__wrap_sock "\n"); #define _SSL__SSLCONTEXT__WRAP_SOCKET_METHODDEF \ - {"_wrap_socket", (PyCFunction)_ssl__SSLContext__wrap_socket, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__}, + {"_wrap_socket", (PyCFunction)_ssl__SSLContext__wrap_socket, METH_FASTCALL, _ssl__SSLContext__wrap_socket__doc__}, static PyObject * _ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock, int server_side, PyObject *hostname_obj); static PyObject * -_ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject *args, PyObject *kwargs) +_ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sock", "server_side", "server_hostname", NULL}; @@ -519,7 +521,7 @@ static PyObject * int server_side; PyObject *hostname_obj = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!i|O:_wrap_socket", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O!i|O:_wrap_socket", _keywords, PySocketModule.Sock_Type, &sock, &server_side, &hostname_obj)) goto exit; return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj); @@ -535,7 +537,7 @@ PyDoc_STRVAR(_ssl__SSLContext__wrap_bio_ "\n"); #define _SSL__SSLCONTEXT__WRAP_BIO_METHODDEF \ - {"_wrap_bio", (PyCFunction)_ssl__SSLContext__wrap_bio, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__}, + {"_wrap_bio", (PyCFunction)_ssl__SSLContext__wrap_bio, METH_FASTCALL, _ssl__SSLContext__wrap_bio__doc__}, static PyObject * _ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming, @@ -543,7 +545,7 @@ static PyObject * PyObject *hostname_obj); static PyObject * -_ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *args, PyObject *kwargs) +_ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"incoming", "outgoing", "server_side", "server_hostname", NULL}; @@ -552,7 +554,7 @@ static PyObject * int server_side; PyObject *hostname_obj = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!i|O:_wrap_bio", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O!O!i|O:_wrap_bio", _keywords, &PySSLMemoryBIO_Type, &incoming, &PySSLMemoryBIO_Type, &outgoing, &server_side, &hostname_obj)) goto exit; return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj); @@ -657,19 +659,19 @@ PyDoc_STRVAR(_ssl__SSLContext_get_ca_cer "been used at least once."); #define _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF \ - {"get_ca_certs", (PyCFunction)_ssl__SSLContext_get_ca_certs, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__}, + {"get_ca_certs", (PyCFunction)_ssl__SSLContext_get_ca_certs, METH_FASTCALL, _ssl__SSLContext_get_ca_certs__doc__}, static PyObject * _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form); static PyObject * -_ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject *args, PyObject *kwargs) +_ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"binary_form", NULL}; int binary_form = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|p:get_ca_certs", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|p:get_ca_certs", _keywords, &binary_form)) goto exit; return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form); @@ -710,20 +712,22 @@ PyDoc_STRVAR(_ssl_MemoryBIO_read__doc__, "distinguish between the two."); #define _SSL_MEMORYBIO_READ_METHODDEF \ - {"read", (PyCFunction)_ssl_MemoryBIO_read, METH_VARARGS, _ssl_MemoryBIO_read__doc__}, + {"read", (PyCFunction)_ssl_MemoryBIO_read, METH_FASTCALL, _ssl_MemoryBIO_read__doc__}, static PyObject * _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len); static PyObject * -_ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject *args) +_ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int len = -1; - if (!PyArg_ParseTuple(args, "|i:read", + if (!PyArg_ParseStack(stack, nargs, "|i:read", &len)) goto exit; + if (!_PyArg_NoKeywords("read()", kwargs)) + goto exit; return_value = _ssl_MemoryBIO_read_impl(self, len); exit: @@ -792,21 +796,23 @@ PyDoc_STRVAR(_ssl_RAND_add__doc__, "string. See RFC 1750."); #define _SSL_RAND_ADD_METHODDEF \ - {"RAND_add", (PyCFunction)_ssl_RAND_add, METH_VARARGS, _ssl_RAND_add__doc__}, + {"RAND_add", (PyCFunction)_ssl_RAND_add, METH_FASTCALL, _ssl_RAND_add__doc__}, static PyObject * _ssl_RAND_add_impl(PyModuleDef *module, Py_buffer *view, double entropy); static PyObject * -_ssl_RAND_add(PyModuleDef *module, PyObject *args) +_ssl_RAND_add(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer view = {NULL, NULL}; double entropy; - if (!PyArg_ParseTuple(args, "s*d:RAND_add", + if (!PyArg_ParseStack(stack, nargs, "s*d:RAND_add", &view, &entropy)) goto exit; + if (!_PyArg_NoKeywords("RAND_add()", kwargs)) + goto exit; return_value = _ssl_RAND_add_impl(module, &view, entropy); exit: @@ -956,20 +962,20 @@ PyDoc_STRVAR(_ssl_txt2obj__doc__, "long name are also matched."); #define _SSL_TXT2OBJ_METHODDEF \ - {"txt2obj", (PyCFunction)_ssl_txt2obj, METH_VARARGS|METH_KEYWORDS, _ssl_txt2obj__doc__}, + {"txt2obj", (PyCFunction)_ssl_txt2obj, METH_FASTCALL, _ssl_txt2obj__doc__}, static PyObject * _ssl_txt2obj_impl(PyModuleDef *module, const char *txt, int name); static PyObject * -_ssl_txt2obj(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_ssl_txt2obj(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"txt", "name", NULL}; const char *txt; int name = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|p:txt2obj", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "s|p:txt2obj", _keywords, &txt, &name)) goto exit; return_value = _ssl_txt2obj_impl(module, txt, name); @@ -1019,19 +1025,19 @@ PyDoc_STRVAR(_ssl_enum_certificates__doc "a set of OIDs or the boolean True."); #define _SSL_ENUM_CERTIFICATES_METHODDEF \ - {"enum_certificates", (PyCFunction)_ssl_enum_certificates, METH_VARARGS|METH_KEYWORDS, _ssl_enum_certificates__doc__}, + {"enum_certificates", (PyCFunction)_ssl_enum_certificates, METH_FASTCALL, _ssl_enum_certificates__doc__}, static PyObject * _ssl_enum_certificates_impl(PyModuleDef *module, const char *store_name); static PyObject * -_ssl_enum_certificates(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_ssl_enum_certificates(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"store_name", NULL}; const char *store_name; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:enum_certificates", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "s:enum_certificates", _keywords, &store_name)) goto exit; return_value = _ssl_enum_certificates_impl(module, store_name); @@ -1056,19 +1062,19 @@ PyDoc_STRVAR(_ssl_enum_crls__doc__, "X509_ASN_ENCODING or PKCS_7_ASN_ENCODING."); #define _SSL_ENUM_CRLS_METHODDEF \ - {"enum_crls", (PyCFunction)_ssl_enum_crls, METH_VARARGS|METH_KEYWORDS, _ssl_enum_crls__doc__}, + {"enum_crls", (PyCFunction)_ssl_enum_crls, METH_FASTCALL, _ssl_enum_crls__doc__}, static PyObject * _ssl_enum_crls_impl(PyModuleDef *module, const char *store_name); static PyObject * -_ssl_enum_crls(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_ssl_enum_crls(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"store_name", NULL}; const char *store_name; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:enum_crls", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "s:enum_crls", _keywords, &store_name)) goto exit; return_value = _ssl_enum_crls_impl(module, store_name); @@ -1102,4 +1108,4 @@ exit: #ifndef _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */ -/*[clinic end generated code: output=a14999cb565a69a2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7e23afae50bd3ecc input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_tkinter.c.h --- a/Modules/clinic/_tkinter.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_tkinter.c.h Thu May 19 13:47:42 2016 +0200 @@ -248,22 +248,24 @@ PyDoc_STRVAR(_tkinter_tkapp_createcomman "\n"); #define _TKINTER_TKAPP_CREATECOMMAND_METHODDEF \ - {"createcommand", (PyCFunction)_tkinter_tkapp_createcommand, METH_VARARGS, _tkinter_tkapp_createcommand__doc__}, + {"createcommand", (PyCFunction)_tkinter_tkapp_createcommand, METH_FASTCALL, _tkinter_tkapp_createcommand__doc__}, static PyObject * _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name, PyObject *func); static PyObject * -_tkinter_tkapp_createcommand(TkappObject *self, PyObject *args) +_tkinter_tkapp_createcommand(TkappObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *name; PyObject *func; - if (!PyArg_ParseTuple(args, "sO:createcommand", + if (!PyArg_ParseStack(stack, nargs, "sO:createcommand", &name, &func)) goto exit; + if (!_PyArg_NoKeywords("createcommand()", kwargs)) + goto exit; return_value = _tkinter_tkapp_createcommand_impl(self, name, func); exit: @@ -303,23 +305,25 @@ PyDoc_STRVAR(_tkinter_tkapp_createfileha "\n"); #define _TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF \ - {"createfilehandler", (PyCFunction)_tkinter_tkapp_createfilehandler, METH_VARARGS, _tkinter_tkapp_createfilehandler__doc__}, + {"createfilehandler", (PyCFunction)_tkinter_tkapp_createfilehandler, METH_FASTCALL, _tkinter_tkapp_createfilehandler__doc__}, static PyObject * _tkinter_tkapp_createfilehandler_impl(TkappObject *self, PyObject *file, int mask, PyObject *func); static PyObject * -_tkinter_tkapp_createfilehandler(TkappObject *self, PyObject *args) +_tkinter_tkapp_createfilehandler(TkappObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *file; int mask; PyObject *func; - if (!PyArg_ParseTuple(args, "OiO:createfilehandler", + if (!PyArg_ParseStack(stack, nargs, "OiO:createfilehandler", &file, &mask, &func)) goto exit; + if (!_PyArg_NoKeywords("createfilehandler()", kwargs)) + goto exit; return_value = _tkinter_tkapp_createfilehandler_impl(self, file, mask, func); exit: @@ -363,22 +367,24 @@ PyDoc_STRVAR(_tkinter_tkapp_createtimerh "\n"); #define _TKINTER_TKAPP_CREATETIMERHANDLER_METHODDEF \ - {"createtimerhandler", (PyCFunction)_tkinter_tkapp_createtimerhandler, METH_VARARGS, _tkinter_tkapp_createtimerhandler__doc__}, + {"createtimerhandler", (PyCFunction)_tkinter_tkapp_createtimerhandler, METH_FASTCALL, _tkinter_tkapp_createtimerhandler__doc__}, static PyObject * _tkinter_tkapp_createtimerhandler_impl(TkappObject *self, int milliseconds, PyObject *func); static PyObject * -_tkinter_tkapp_createtimerhandler(TkappObject *self, PyObject *args) +_tkinter_tkapp_createtimerhandler(TkappObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int milliseconds; PyObject *func; - if (!PyArg_ParseTuple(args, "iO:createtimerhandler", + if (!PyArg_ParseStack(stack, nargs, "iO:createtimerhandler", &milliseconds, &func)) goto exit; + if (!_PyArg_NoKeywords("createtimerhandler()", kwargs)) + goto exit; return_value = _tkinter_tkapp_createtimerhandler_impl(self, milliseconds, func); exit: @@ -391,20 +397,22 @@ PyDoc_STRVAR(_tkinter_tkapp_mainloop__do "\n"); #define _TKINTER_TKAPP_MAINLOOP_METHODDEF \ - {"mainloop", (PyCFunction)_tkinter_tkapp_mainloop, METH_VARARGS, _tkinter_tkapp_mainloop__doc__}, + {"mainloop", (PyCFunction)_tkinter_tkapp_mainloop, METH_FASTCALL, _tkinter_tkapp_mainloop__doc__}, static PyObject * _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold); static PyObject * -_tkinter_tkapp_mainloop(TkappObject *self, PyObject *args) +_tkinter_tkapp_mainloop(TkappObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int threshold = 0; - if (!PyArg_ParseTuple(args, "|i:mainloop", + if (!PyArg_ParseStack(stack, nargs, "|i:mainloop", &threshold)) goto exit; + if (!_PyArg_NoKeywords("mainloop()", kwargs)) + goto exit; return_value = _tkinter_tkapp_mainloop_impl(self, threshold); exit: @@ -417,20 +425,22 @@ PyDoc_STRVAR(_tkinter_tkapp_dooneevent__ "\n"); #define _TKINTER_TKAPP_DOONEEVENT_METHODDEF \ - {"dooneevent", (PyCFunction)_tkinter_tkapp_dooneevent, METH_VARARGS, _tkinter_tkapp_dooneevent__doc__}, + {"dooneevent", (PyCFunction)_tkinter_tkapp_dooneevent, METH_FASTCALL, _tkinter_tkapp_dooneevent__doc__}, static PyObject * _tkinter_tkapp_dooneevent_impl(TkappObject *self, int flags); static PyObject * -_tkinter_tkapp_dooneevent(TkappObject *self, PyObject *args) +_tkinter_tkapp_dooneevent(TkappObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int flags = 0; - if (!PyArg_ParseTuple(args, "|i:dooneevent", + if (!PyArg_ParseStack(stack, nargs, "|i:dooneevent", &flags)) goto exit; + if (!_PyArg_NoKeywords("dooneevent()", kwargs)) + goto exit; return_value = _tkinter_tkapp_dooneevent_impl(self, flags); exit: @@ -529,7 +539,7 @@ PyDoc_STRVAR(_tkinter_create__doc__, " if not None, then pass -use to wish"); #define _TKINTER_CREATE_METHODDEF \ - {"create", (PyCFunction)_tkinter_create, METH_VARARGS, _tkinter_create__doc__}, + {"create", (PyCFunction)_tkinter_create, METH_FASTCALL, _tkinter_create__doc__}, static PyObject * _tkinter_create_impl(PyModuleDef *module, const char *screenName, @@ -538,7 +548,7 @@ static PyObject * const char *use); static PyObject * -_tkinter_create(PyModuleDef *module, PyObject *args) +_tkinter_create(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *screenName = NULL; @@ -550,9 +560,11 @@ static PyObject * int sync = 0; const char *use = NULL; - if (!PyArg_ParseTuple(args, "|zssiiiiz:create", + if (!PyArg_ParseStack(stack, nargs, "|zssiiiiz:create", &screenName, &baseName, &className, &interactive, &wantobjects, &wantTk, &sync, &use)) goto exit; + if (!_PyArg_NoKeywords("create()", kwargs)) + goto exit; return_value = _tkinter_create_impl(module, screenName, baseName, className, interactive, wantobjects, wantTk, sync, use); exit: @@ -621,4 +633,4 @@ exit: #ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */ -/*[clinic end generated code: output=6dd667b91cf8addd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=880b0aa12dde98a7 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/_winapi.c.h --- a/Modules/clinic/_winapi.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/_winapi.c.h Thu May 19 13:47:42 2016 +0200 @@ -93,21 +93,21 @@ PyDoc_STRVAR(_winapi_ConnectNamedPipe__d "\n"); #define _WINAPI_CONNECTNAMEDPIPE_METHODDEF \ - {"ConnectNamedPipe", (PyCFunction)_winapi_ConnectNamedPipe, METH_VARARGS|METH_KEYWORDS, _winapi_ConnectNamedPipe__doc__}, + {"ConnectNamedPipe", (PyCFunction)_winapi_ConnectNamedPipe, METH_FASTCALL, _winapi_ConnectNamedPipe__doc__}, static PyObject * _winapi_ConnectNamedPipe_impl(PyModuleDef *module, HANDLE handle, int use_overlapped); static PyObject * -_winapi_ConnectNamedPipe(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_winapi_ConnectNamedPipe(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"handle", "overlapped", NULL}; HANDLE handle; int use_overlapped = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "|i:ConnectNamedPipe", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "" F_HANDLE "|i:ConnectNamedPipe", _keywords, &handle, &use_overlapped)) goto exit; return_value = _winapi_ConnectNamedPipe_impl(module, handle, use_overlapped); @@ -124,7 +124,7 @@ PyDoc_STRVAR(_winapi_CreateFile__doc__, "\n"); #define _WINAPI_CREATEFILE_METHODDEF \ - {"CreateFile", (PyCFunction)_winapi_CreateFile, METH_VARARGS, _winapi_CreateFile__doc__}, + {"CreateFile", (PyCFunction)_winapi_CreateFile, METH_FASTCALL, _winapi_CreateFile__doc__}, static HANDLE _winapi_CreateFile_impl(PyModuleDef *module, LPCTSTR file_name, @@ -134,7 +134,7 @@ static HANDLE DWORD flags_and_attributes, HANDLE template_file); static PyObject * -_winapi_CreateFile(PyModuleDef *module, PyObject *args) +_winapi_CreateFile(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; LPCTSTR file_name; @@ -146,9 +146,11 @@ static PyObject * HANDLE template_file; HANDLE _return_value; - if (!PyArg_ParseTuple(args, "skk" F_POINTER "kk" F_HANDLE ":CreateFile", + if (!PyArg_ParseStack(stack, nargs, "skk" F_POINTER "kk" F_HANDLE ":CreateFile", &file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file)) goto exit; + if (!_PyArg_NoKeywords("CreateFile()", kwargs)) + goto exit; _return_value = _winapi_CreateFile_impl(module, file_name, desired_access, share_mode, security_attributes, creation_disposition, flags_and_attributes, template_file); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) goto exit; @@ -166,22 +168,24 @@ PyDoc_STRVAR(_winapi_CreateJunction__doc "\n"); #define _WINAPI_CREATEJUNCTION_METHODDEF \ - {"CreateJunction", (PyCFunction)_winapi_CreateJunction, METH_VARARGS, _winapi_CreateJunction__doc__}, + {"CreateJunction", (PyCFunction)_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__}, static PyObject * _winapi_CreateJunction_impl(PyModuleDef *module, LPWSTR src_path, LPWSTR dst_path); static PyObject * -_winapi_CreateJunction(PyModuleDef *module, PyObject *args) +_winapi_CreateJunction(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; LPWSTR src_path; LPWSTR dst_path; - if (!PyArg_ParseTuple(args, "uu:CreateJunction", + if (!PyArg_ParseStack(stack, nargs, "uu:CreateJunction", &src_path, &dst_path)) goto exit; + if (!_PyArg_NoKeywords("CreateJunction()", kwargs)) + goto exit; return_value = _winapi_CreateJunction_impl(module, src_path, dst_path); exit: @@ -196,7 +200,7 @@ PyDoc_STRVAR(_winapi_CreateNamedPipe__do "\n"); #define _WINAPI_CREATENAMEDPIPE_METHODDEF \ - {"CreateNamedPipe", (PyCFunction)_winapi_CreateNamedPipe, METH_VARARGS, _winapi_CreateNamedPipe__doc__}, + {"CreateNamedPipe", (PyCFunction)_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__}, static HANDLE _winapi_CreateNamedPipe_impl(PyModuleDef *module, LPCTSTR name, @@ -206,7 +210,7 @@ static HANDLE LPSECURITY_ATTRIBUTES security_attributes); static PyObject * -_winapi_CreateNamedPipe(PyModuleDef *module, PyObject *args) +_winapi_CreateNamedPipe(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; LPCTSTR name; @@ -219,9 +223,11 @@ static PyObject * LPSECURITY_ATTRIBUTES security_attributes; HANDLE _return_value; - if (!PyArg_ParseTuple(args, "skkkkkk" F_POINTER ":CreateNamedPipe", + if (!PyArg_ParseStack(stack, nargs, "skkkkkk" F_POINTER ":CreateNamedPipe", &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) goto exit; + if (!_PyArg_NoKeywords("CreateNamedPipe()", kwargs)) + goto exit; _return_value = _winapi_CreateNamedPipe_impl(module, name, open_mode, pipe_mode, max_instances, out_buffer_size, in_buffer_size, default_timeout, security_attributes); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) goto exit; @@ -245,22 +251,24 @@ PyDoc_STRVAR(_winapi_CreatePipe__doc__, "Returns a 2-tuple of handles, to the read and write ends of the pipe."); #define _WINAPI_CREATEPIPE_METHODDEF \ - {"CreatePipe", (PyCFunction)_winapi_CreatePipe, METH_VARARGS, _winapi_CreatePipe__doc__}, + {"CreatePipe", (PyCFunction)_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__}, static PyObject * _winapi_CreatePipe_impl(PyModuleDef *module, PyObject *pipe_attrs, DWORD size); static PyObject * -_winapi_CreatePipe(PyModuleDef *module, PyObject *args) +_winapi_CreatePipe(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *pipe_attrs; DWORD size; - if (!PyArg_ParseTuple(args, "Ok:CreatePipe", + if (!PyArg_ParseStack(stack, nargs, "Ok:CreatePipe", &pipe_attrs, &size)) goto exit; + if (!_PyArg_NoKeywords("CreatePipe()", kwargs)) + goto exit; return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size); exit: @@ -284,7 +292,7 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc_ "process ID, and thread ID."); #define _WINAPI_CREATEPROCESS_METHODDEF \ - {"CreateProcess", (PyCFunction)_winapi_CreateProcess, METH_VARARGS, _winapi_CreateProcess__doc__}, + {"CreateProcess", (PyCFunction)_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__}, static PyObject * _winapi_CreateProcess_impl(PyModuleDef *module, Py_UNICODE *application_name, @@ -295,7 +303,7 @@ static PyObject * PyObject *startup_info); static PyObject * -_winapi_CreateProcess(PyModuleDef *module, PyObject *args) +_winapi_CreateProcess(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_UNICODE *application_name; @@ -308,9 +316,11 @@ static PyObject * Py_UNICODE *current_directory; PyObject *startup_info; - if (!PyArg_ParseTuple(args, "ZZOOikOZO:CreateProcess", + if (!PyArg_ParseStack(stack, nargs, "ZZOOikOZO:CreateProcess", &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, ¤t_directory, &startup_info)) goto exit; + if (!_PyArg_NoKeywords("CreateProcess()", kwargs)) + goto exit; return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info); exit: @@ -330,7 +340,7 @@ PyDoc_STRVAR(_winapi_DuplicateHandle__do "through both handles."); #define _WINAPI_DUPLICATEHANDLE_METHODDEF \ - {"DuplicateHandle", (PyCFunction)_winapi_DuplicateHandle, METH_VARARGS, _winapi_DuplicateHandle__doc__}, + {"DuplicateHandle", (PyCFunction)_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__}, static HANDLE _winapi_DuplicateHandle_impl(PyModuleDef *module, @@ -341,7 +351,7 @@ static HANDLE DWORD options); static PyObject * -_winapi_DuplicateHandle(PyModuleDef *module, PyObject *args) +_winapi_DuplicateHandle(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HANDLE source_process_handle; @@ -352,9 +362,11 @@ static PyObject * DWORD options = 0; HANDLE _return_value; - if (!PyArg_ParseTuple(args, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle", + if (!PyArg_ParseStack(stack, nargs, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle", &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) goto exit; + if (!_PyArg_NoKeywords("DuplicateHandle()", kwargs)) + goto exit; _return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) goto exit; @@ -579,14 +591,14 @@ PyDoc_STRVAR(_winapi_OpenProcess__doc__, "\n"); #define _WINAPI_OPENPROCESS_METHODDEF \ - {"OpenProcess", (PyCFunction)_winapi_OpenProcess, METH_VARARGS, _winapi_OpenProcess__doc__}, + {"OpenProcess", (PyCFunction)_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__}, static HANDLE _winapi_OpenProcess_impl(PyModuleDef *module, DWORD desired_access, BOOL inherit_handle, DWORD process_id); static PyObject * -_winapi_OpenProcess(PyModuleDef *module, PyObject *args) +_winapi_OpenProcess(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; DWORD desired_access; @@ -594,9 +606,11 @@ static PyObject * DWORD process_id; HANDLE _return_value; - if (!PyArg_ParseTuple(args, "kik:OpenProcess", + if (!PyArg_ParseStack(stack, nargs, "kik:OpenProcess", &desired_access, &inherit_handle, &process_id)) goto exit; + if (!_PyArg_NoKeywords("OpenProcess()", kwargs)) + goto exit; _return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) goto exit; @@ -614,21 +628,23 @@ PyDoc_STRVAR(_winapi_PeekNamedPipe__doc_ "\n"); #define _WINAPI_PEEKNAMEDPIPE_METHODDEF \ - {"PeekNamedPipe", (PyCFunction)_winapi_PeekNamedPipe, METH_VARARGS, _winapi_PeekNamedPipe__doc__}, + {"PeekNamedPipe", (PyCFunction)_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__}, static PyObject * _winapi_PeekNamedPipe_impl(PyModuleDef *module, HANDLE handle, int size); static PyObject * -_winapi_PeekNamedPipe(PyModuleDef *module, PyObject *args) +_winapi_PeekNamedPipe(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HANDLE handle; int size = 0; - if (!PyArg_ParseTuple(args, "" F_HANDLE "|i:PeekNamedPipe", + if (!PyArg_ParseStack(stack, nargs, "" F_HANDLE "|i:PeekNamedPipe", &handle, &size)) goto exit; + if (!_PyArg_NoKeywords("PeekNamedPipe()", kwargs)) + goto exit; return_value = _winapi_PeekNamedPipe_impl(module, handle, size); exit: @@ -641,14 +657,14 @@ PyDoc_STRVAR(_winapi_ReadFile__doc__, "\n"); #define _WINAPI_READFILE_METHODDEF \ - {"ReadFile", (PyCFunction)_winapi_ReadFile, METH_VARARGS|METH_KEYWORDS, _winapi_ReadFile__doc__}, + {"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL, _winapi_ReadFile__doc__}, static PyObject * _winapi_ReadFile_impl(PyModuleDef *module, HANDLE handle, int size, int use_overlapped); static PyObject * -_winapi_ReadFile(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_winapi_ReadFile(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"handle", "size", "overlapped", NULL}; @@ -656,7 +672,7 @@ static PyObject * int size; int use_overlapped = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "i|i:ReadFile", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "" F_HANDLE "i|i:ReadFile", _keywords, &handle, &size, &use_overlapped)) goto exit; return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped); @@ -672,7 +688,7 @@ PyDoc_STRVAR(_winapi_SetNamedPipeHandleS "\n"); #define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF \ - {"SetNamedPipeHandleState", (PyCFunction)_winapi_SetNamedPipeHandleState, METH_VARARGS, _winapi_SetNamedPipeHandleState__doc__}, + {"SetNamedPipeHandleState", (PyCFunction)_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__}, static PyObject * _winapi_SetNamedPipeHandleState_impl(PyModuleDef *module, HANDLE named_pipe, @@ -681,7 +697,7 @@ static PyObject * PyObject *collect_data_timeout); static PyObject * -_winapi_SetNamedPipeHandleState(PyModuleDef *module, PyObject *args) +_winapi_SetNamedPipeHandleState(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HANDLE named_pipe; @@ -689,9 +705,11 @@ static PyObject * PyObject *max_collection_count; PyObject *collect_data_timeout; - if (!PyArg_ParseTuple(args, "" F_HANDLE "OOO:SetNamedPipeHandleState", + if (!PyArg_ParseStack(stack, nargs, "" F_HANDLE "OOO:SetNamedPipeHandleState", &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) goto exit; + if (!_PyArg_NoKeywords("SetNamedPipeHandleState()", kwargs)) + goto exit; return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout); exit: @@ -705,22 +723,24 @@ PyDoc_STRVAR(_winapi_TerminateProcess__d "Terminate the specified process and all of its threads."); #define _WINAPI_TERMINATEPROCESS_METHODDEF \ - {"TerminateProcess", (PyCFunction)_winapi_TerminateProcess, METH_VARARGS, _winapi_TerminateProcess__doc__}, + {"TerminateProcess", (PyCFunction)_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__}, static PyObject * _winapi_TerminateProcess_impl(PyModuleDef *module, HANDLE handle, UINT exit_code); static PyObject * -_winapi_TerminateProcess(PyModuleDef *module, PyObject *args) +_winapi_TerminateProcess(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HANDLE handle; UINT exit_code; - if (!PyArg_ParseTuple(args, "" F_HANDLE "I:TerminateProcess", + if (!PyArg_ParseStack(stack, nargs, "" F_HANDLE "I:TerminateProcess", &handle, &exit_code)) goto exit; + if (!_PyArg_NoKeywords("TerminateProcess()", kwargs)) + goto exit; return_value = _winapi_TerminateProcess_impl(module, handle, exit_code); exit: @@ -733,21 +753,23 @@ PyDoc_STRVAR(_winapi_WaitNamedPipe__doc_ "\n"); #define _WINAPI_WAITNAMEDPIPE_METHODDEF \ - {"WaitNamedPipe", (PyCFunction)_winapi_WaitNamedPipe, METH_VARARGS, _winapi_WaitNamedPipe__doc__}, + {"WaitNamedPipe", (PyCFunction)_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__}, static PyObject * _winapi_WaitNamedPipe_impl(PyModuleDef *module, LPCTSTR name, DWORD timeout); static PyObject * -_winapi_WaitNamedPipe(PyModuleDef *module, PyObject *args) +_winapi_WaitNamedPipe(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; LPCTSTR name; DWORD timeout; - if (!PyArg_ParseTuple(args, "sk:WaitNamedPipe", + if (!PyArg_ParseStack(stack, nargs, "sk:WaitNamedPipe", &name, &timeout)) goto exit; + if (!_PyArg_NoKeywords("WaitNamedPipe()", kwargs)) + goto exit; return_value = _winapi_WaitNamedPipe_impl(module, name, timeout); exit: @@ -761,7 +783,7 @@ PyDoc_STRVAR(_winapi_WaitForMultipleObje "\n"); #define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF \ - {"WaitForMultipleObjects", (PyCFunction)_winapi_WaitForMultipleObjects, METH_VARARGS, _winapi_WaitForMultipleObjects__doc__}, + {"WaitForMultipleObjects", (PyCFunction)_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__}, static PyObject * _winapi_WaitForMultipleObjects_impl(PyModuleDef *module, @@ -769,16 +791,18 @@ static PyObject * DWORD milliseconds); static PyObject * -_winapi_WaitForMultipleObjects(PyModuleDef *module, PyObject *args) +_winapi_WaitForMultipleObjects(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *handle_seq; BOOL wait_flag; DWORD milliseconds = INFINITE; - if (!PyArg_ParseTuple(args, "Oi|k:WaitForMultipleObjects", + if (!PyArg_ParseStack(stack, nargs, "Oi|k:WaitForMultipleObjects", &handle_seq, &wait_flag, &milliseconds)) goto exit; + if (!_PyArg_NoKeywords("WaitForMultipleObjects()", kwargs)) + goto exit; return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds); exit: @@ -796,23 +820,25 @@ PyDoc_STRVAR(_winapi_WaitForSingleObject "in milliseconds."); #define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF \ - {"WaitForSingleObject", (PyCFunction)_winapi_WaitForSingleObject, METH_VARARGS, _winapi_WaitForSingleObject__doc__}, + {"WaitForSingleObject", (PyCFunction)_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__}, static long _winapi_WaitForSingleObject_impl(PyModuleDef *module, HANDLE handle, DWORD milliseconds); static PyObject * -_winapi_WaitForSingleObject(PyModuleDef *module, PyObject *args) +_winapi_WaitForSingleObject(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HANDLE handle; DWORD milliseconds; long _return_value; - if (!PyArg_ParseTuple(args, "" F_HANDLE "k:WaitForSingleObject", + if (!PyArg_ParseStack(stack, nargs, "" F_HANDLE "k:WaitForSingleObject", &handle, &milliseconds)) goto exit; + if (!_PyArg_NoKeywords("WaitForSingleObject()", kwargs)) + goto exit; _return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -828,14 +854,14 @@ PyDoc_STRVAR(_winapi_WriteFile__doc__, "\n"); #define _WINAPI_WRITEFILE_METHODDEF \ - {"WriteFile", (PyCFunction)_winapi_WriteFile, METH_VARARGS|METH_KEYWORDS, _winapi_WriteFile__doc__}, + {"WriteFile", (PyCFunction)_winapi_WriteFile, METH_FASTCALL, _winapi_WriteFile__doc__}, static PyObject * _winapi_WriteFile_impl(PyModuleDef *module, HANDLE handle, PyObject *buffer, int use_overlapped); static PyObject * -_winapi_WriteFile(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_winapi_WriteFile(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"handle", "buffer", "overlapped", NULL}; @@ -843,7 +869,7 @@ static PyObject * PyObject *buffer; int use_overlapped = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "O|i:WriteFile", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "" F_HANDLE "O|i:WriteFile", _keywords, &handle, &buffer, &use_overlapped)) goto exit; return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped); @@ -851,4 +877,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=98771c6584056d19 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4532861b558e0781 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/arraymodule.c.h --- a/Modules/clinic/arraymodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/arraymodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -65,20 +65,22 @@ PyDoc_STRVAR(array_array_pop__doc__, "i defaults to -1."); #define ARRAY_ARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)array_array_pop, METH_VARARGS, array_array_pop__doc__}, + {"pop", (PyCFunction)array_array_pop, METH_FASTCALL, array_array_pop__doc__}, static PyObject * array_array_pop_impl(arrayobject *self, Py_ssize_t i); static PyObject * -array_array_pop(arrayobject *self, PyObject *args) +array_array_pop(arrayobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t i = -1; - if (!PyArg_ParseTuple(args, "|n:pop", + if (!PyArg_ParseStack(stack, nargs, "|n:pop", &i)) goto exit; + if (!_PyArg_NoKeywords("pop()", kwargs)) + goto exit; return_value = array_array_pop_impl(self, i); exit: @@ -101,21 +103,23 @@ PyDoc_STRVAR(array_array_insert__doc__, "Insert a new item v into the array before position i."); #define ARRAY_ARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)array_array_insert, METH_VARARGS, array_array_insert__doc__}, + {"insert", (PyCFunction)array_array_insert, METH_FASTCALL, array_array_insert__doc__}, static PyObject * array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v); static PyObject * -array_array_insert(arrayobject *self, PyObject *args) +array_array_insert(arrayobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t i; PyObject *v; - if (!PyArg_ParseTuple(args, "nO:insert", + if (!PyArg_ParseStack(stack, nargs, "nO:insert", &i, &v)) goto exit; + if (!_PyArg_NoKeywords("insert()", kwargs)) + goto exit; return_value = array_array_insert_impl(self, i, v); exit: @@ -198,21 +202,23 @@ PyDoc_STRVAR(array_array_fromfile__doc__ "Read n objects from the file object f and append them to the end of the array."); #define ARRAY_ARRAY_FROMFILE_METHODDEF \ - {"fromfile", (PyCFunction)array_array_fromfile, METH_VARARGS, array_array_fromfile__doc__}, + {"fromfile", (PyCFunction)array_array_fromfile, METH_FASTCALL, array_array_fromfile__doc__}, static PyObject * array_array_fromfile_impl(arrayobject *self, PyObject *f, Py_ssize_t n); static PyObject * -array_array_fromfile(arrayobject *self, PyObject *args) +array_array_fromfile(arrayobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *f; Py_ssize_t n; - if (!PyArg_ParseTuple(args, "On:fromfile", + if (!PyArg_ParseStack(stack, nargs, "On:fromfile", &f, &n)) goto exit; + if (!_PyArg_NoKeywords("fromfile()", kwargs)) + goto exit; return_value = array_array_fromfile_impl(self, f, n); exit: @@ -435,7 +441,7 @@ PyDoc_STRVAR(array__array_reconstructor_ "Internal. Used for pickling support."); #define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \ - {"_array_reconstructor", (PyCFunction)array__array_reconstructor, METH_VARARGS, array__array_reconstructor__doc__}, + {"_array_reconstructor", (PyCFunction)array__array_reconstructor, METH_FASTCALL, array__array_reconstructor__doc__}, static PyObject * array__array_reconstructor_impl(PyModuleDef *module, PyTypeObject *arraytype, @@ -444,7 +450,7 @@ array__array_reconstructor_impl(PyModule PyObject *items); static PyObject * -array__array_reconstructor(PyModuleDef *module, PyObject *args) +array__array_reconstructor(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyTypeObject *arraytype; @@ -452,9 +458,11 @@ array__array_reconstructor(PyModuleDef * enum machine_format_code mformat_code; PyObject *items; - if (!PyArg_ParseTuple(args, "OCiO:_array_reconstructor", + if (!PyArg_ParseStack(stack, nargs, "OCiO:_array_reconstructor", &arraytype, &typecode, &mformat_code, &items)) goto exit; + if (!_PyArg_NoKeywords("_array_reconstructor()", kwargs)) + goto exit; return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items); exit: @@ -496,4 +504,4 @@ PyDoc_STRVAR(array_arrayiterator___setst #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \ {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__}, -/*[clinic end generated code: output=d2e82c65ea841cfc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3fc95b5021b38b1e input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/audioop.c.h --- a/Modules/clinic/audioop.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/audioop.c.h Thu May 19 13:47:42 2016 +0200 @@ -9,23 +9,25 @@ PyDoc_STRVAR(audioop_getsample__doc__, "Return the value of sample index from the fragment."); #define AUDIOOP_GETSAMPLE_METHODDEF \ - {"getsample", (PyCFunction)audioop_getsample, METH_VARARGS, audioop_getsample__doc__}, + {"getsample", (PyCFunction)audioop_getsample, METH_FASTCALL, audioop_getsample__doc__}, static PyObject * audioop_getsample_impl(PyModuleDef *module, Py_buffer *fragment, int width, Py_ssize_t index); static PyObject * -audioop_getsample(PyModuleDef *module, PyObject *args) +audioop_getsample(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; Py_ssize_t index; - if (!PyArg_ParseTuple(args, "y*in:getsample", + if (!PyArg_ParseStack(stack, nargs, "y*in:getsample", &fragment, &width, &index)) goto exit; + if (!_PyArg_NoKeywords("getsample()", kwargs)) + goto exit; return_value = audioop_getsample_impl(module, &fragment, width, index); exit: @@ -43,21 +45,23 @@ PyDoc_STRVAR(audioop_max__doc__, "Return the maximum of the absolute value of all samples in a fragment."); #define AUDIOOP_MAX_METHODDEF \ - {"max", (PyCFunction)audioop_max, METH_VARARGS, audioop_max__doc__}, + {"max", (PyCFunction)audioop_max, METH_FASTCALL, audioop_max__doc__}, static PyObject * audioop_max_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_max(PyModuleDef *module, PyObject *args) +audioop_max(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:max", + if (!PyArg_ParseStack(stack, nargs, "y*i:max", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("max()", kwargs)) + goto exit; return_value = audioop_max_impl(module, &fragment, width); exit: @@ -75,21 +79,23 @@ PyDoc_STRVAR(audioop_minmax__doc__, "Return the minimum and maximum values of all samples in the sound fragment."); #define AUDIOOP_MINMAX_METHODDEF \ - {"minmax", (PyCFunction)audioop_minmax, METH_VARARGS, audioop_minmax__doc__}, + {"minmax", (PyCFunction)audioop_minmax, METH_FASTCALL, audioop_minmax__doc__}, static PyObject * audioop_minmax_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_minmax(PyModuleDef *module, PyObject *args) +audioop_minmax(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:minmax", + if (!PyArg_ParseStack(stack, nargs, "y*i:minmax", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("minmax()", kwargs)) + goto exit; return_value = audioop_minmax_impl(module, &fragment, width); exit: @@ -107,21 +113,23 @@ PyDoc_STRVAR(audioop_avg__doc__, "Return the average over all samples in the fragment."); #define AUDIOOP_AVG_METHODDEF \ - {"avg", (PyCFunction)audioop_avg, METH_VARARGS, audioop_avg__doc__}, + {"avg", (PyCFunction)audioop_avg, METH_FASTCALL, audioop_avg__doc__}, static PyObject * audioop_avg_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_avg(PyModuleDef *module, PyObject *args) +audioop_avg(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:avg", + if (!PyArg_ParseStack(stack, nargs, "y*i:avg", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("avg()", kwargs)) + goto exit; return_value = audioop_avg_impl(module, &fragment, width); exit: @@ -139,21 +147,23 @@ PyDoc_STRVAR(audioop_rms__doc__, "Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n)."); #define AUDIOOP_RMS_METHODDEF \ - {"rms", (PyCFunction)audioop_rms, METH_VARARGS, audioop_rms__doc__}, + {"rms", (PyCFunction)audioop_rms, METH_FASTCALL, audioop_rms__doc__}, static PyObject * audioop_rms_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_rms(PyModuleDef *module, PyObject *args) +audioop_rms(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:rms", + if (!PyArg_ParseStack(stack, nargs, "y*i:rms", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("rms()", kwargs)) + goto exit; return_value = audioop_rms_impl(module, &fragment, width); exit: @@ -171,22 +181,24 @@ PyDoc_STRVAR(audioop_findfit__doc__, "Try to match reference as well as possible to a portion of fragment."); #define AUDIOOP_FINDFIT_METHODDEF \ - {"findfit", (PyCFunction)audioop_findfit, METH_VARARGS, audioop_findfit__doc__}, + {"findfit", (PyCFunction)audioop_findfit, METH_FASTCALL, audioop_findfit__doc__}, static PyObject * audioop_findfit_impl(PyModuleDef *module, Py_buffer *fragment, Py_buffer *reference); static PyObject * -audioop_findfit(PyModuleDef *module, PyObject *args) +audioop_findfit(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; Py_buffer reference = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:findfit", + if (!PyArg_ParseStack(stack, nargs, "y*y*:findfit", &fragment, &reference)) goto exit; + if (!_PyArg_NoKeywords("findfit()", kwargs)) + goto exit; return_value = audioop_findfit_impl(module, &fragment, &reference); exit: @@ -207,22 +219,24 @@ PyDoc_STRVAR(audioop_findfactor__doc__, "Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal."); #define AUDIOOP_FINDFACTOR_METHODDEF \ - {"findfactor", (PyCFunction)audioop_findfactor, METH_VARARGS, audioop_findfactor__doc__}, + {"findfactor", (PyCFunction)audioop_findfactor, METH_FASTCALL, audioop_findfactor__doc__}, static PyObject * audioop_findfactor_impl(PyModuleDef *module, Py_buffer *fragment, Py_buffer *reference); static PyObject * -audioop_findfactor(PyModuleDef *module, PyObject *args) +audioop_findfactor(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; Py_buffer reference = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:findfactor", + if (!PyArg_ParseStack(stack, nargs, "y*y*:findfactor", &fragment, &reference)) goto exit; + if (!_PyArg_NoKeywords("findfactor()", kwargs)) + goto exit; return_value = audioop_findfactor_impl(module, &fragment, &reference); exit: @@ -243,22 +257,24 @@ PyDoc_STRVAR(audioop_findmax__doc__, "Search fragment for a slice of specified number of samples with maximum energy."); #define AUDIOOP_FINDMAX_METHODDEF \ - {"findmax", (PyCFunction)audioop_findmax, METH_VARARGS, audioop_findmax__doc__}, + {"findmax", (PyCFunction)audioop_findmax, METH_FASTCALL, audioop_findmax__doc__}, static PyObject * audioop_findmax_impl(PyModuleDef *module, Py_buffer *fragment, Py_ssize_t length); static PyObject * -audioop_findmax(PyModuleDef *module, PyObject *args) +audioop_findmax(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; Py_ssize_t length; - if (!PyArg_ParseTuple(args, "y*n:findmax", + if (!PyArg_ParseStack(stack, nargs, "y*n:findmax", &fragment, &length)) goto exit; + if (!_PyArg_NoKeywords("findmax()", kwargs)) + goto exit; return_value = audioop_findmax_impl(module, &fragment, length); exit: @@ -276,21 +292,23 @@ PyDoc_STRVAR(audioop_avgpp__doc__, "Return the average peak-peak value over all samples in the fragment."); #define AUDIOOP_AVGPP_METHODDEF \ - {"avgpp", (PyCFunction)audioop_avgpp, METH_VARARGS, audioop_avgpp__doc__}, + {"avgpp", (PyCFunction)audioop_avgpp, METH_FASTCALL, audioop_avgpp__doc__}, static PyObject * audioop_avgpp_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_avgpp(PyModuleDef *module, PyObject *args) +audioop_avgpp(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:avgpp", + if (!PyArg_ParseStack(stack, nargs, "y*i:avgpp", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("avgpp()", kwargs)) + goto exit; return_value = audioop_avgpp_impl(module, &fragment, width); exit: @@ -308,21 +326,23 @@ PyDoc_STRVAR(audioop_maxpp__doc__, "Return the maximum peak-peak value in the sound fragment."); #define AUDIOOP_MAXPP_METHODDEF \ - {"maxpp", (PyCFunction)audioop_maxpp, METH_VARARGS, audioop_maxpp__doc__}, + {"maxpp", (PyCFunction)audioop_maxpp, METH_FASTCALL, audioop_maxpp__doc__}, static PyObject * audioop_maxpp_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_maxpp(PyModuleDef *module, PyObject *args) +audioop_maxpp(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:maxpp", + if (!PyArg_ParseStack(stack, nargs, "y*i:maxpp", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("maxpp()", kwargs)) + goto exit; return_value = audioop_maxpp_impl(module, &fragment, width); exit: @@ -340,21 +360,23 @@ PyDoc_STRVAR(audioop_cross__doc__, "Return the number of zero crossings in the fragment passed as an argument."); #define AUDIOOP_CROSS_METHODDEF \ - {"cross", (PyCFunction)audioop_cross, METH_VARARGS, audioop_cross__doc__}, + {"cross", (PyCFunction)audioop_cross, METH_FASTCALL, audioop_cross__doc__}, static PyObject * audioop_cross_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_cross(PyModuleDef *module, PyObject *args) +audioop_cross(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:cross", + if (!PyArg_ParseStack(stack, nargs, "y*i:cross", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("cross()", kwargs)) + goto exit; return_value = audioop_cross_impl(module, &fragment, width); exit: @@ -372,23 +394,25 @@ PyDoc_STRVAR(audioop_mul__doc__, "Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor."); #define AUDIOOP_MUL_METHODDEF \ - {"mul", (PyCFunction)audioop_mul, METH_VARARGS, audioop_mul__doc__}, + {"mul", (PyCFunction)audioop_mul, METH_FASTCALL, audioop_mul__doc__}, static PyObject * audioop_mul_impl(PyModuleDef *module, Py_buffer *fragment, int width, double factor); static PyObject * -audioop_mul(PyModuleDef *module, PyObject *args) +audioop_mul(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; double factor; - if (!PyArg_ParseTuple(args, "y*id:mul", + if (!PyArg_ParseStack(stack, nargs, "y*id:mul", &fragment, &width, &factor)) goto exit; + if (!_PyArg_NoKeywords("mul()", kwargs)) + goto exit; return_value = audioop_mul_impl(module, &fragment, width, factor); exit: @@ -406,14 +430,14 @@ PyDoc_STRVAR(audioop_tomono__doc__, "Convert a stereo fragment to a mono fragment."); #define AUDIOOP_TOMONO_METHODDEF \ - {"tomono", (PyCFunction)audioop_tomono, METH_VARARGS, audioop_tomono__doc__}, + {"tomono", (PyCFunction)audioop_tomono, METH_FASTCALL, audioop_tomono__doc__}, static PyObject * audioop_tomono_impl(PyModuleDef *module, Py_buffer *fragment, int width, double lfactor, double rfactor); static PyObject * -audioop_tomono(PyModuleDef *module, PyObject *args) +audioop_tomono(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; @@ -421,9 +445,11 @@ audioop_tomono(PyModuleDef *module, PyOb double lfactor; double rfactor; - if (!PyArg_ParseTuple(args, "y*idd:tomono", + if (!PyArg_ParseStack(stack, nargs, "y*idd:tomono", &fragment, &width, &lfactor, &rfactor)) goto exit; + if (!_PyArg_NoKeywords("tomono()", kwargs)) + goto exit; return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor); exit: @@ -441,14 +467,14 @@ PyDoc_STRVAR(audioop_tostereo__doc__, "Generate a stereo fragment from a mono fragment."); #define AUDIOOP_TOSTEREO_METHODDEF \ - {"tostereo", (PyCFunction)audioop_tostereo, METH_VARARGS, audioop_tostereo__doc__}, + {"tostereo", (PyCFunction)audioop_tostereo, METH_FASTCALL, audioop_tostereo__doc__}, static PyObject * audioop_tostereo_impl(PyModuleDef *module, Py_buffer *fragment, int width, double lfactor, double rfactor); static PyObject * -audioop_tostereo(PyModuleDef *module, PyObject *args) +audioop_tostereo(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; @@ -456,9 +482,11 @@ audioop_tostereo(PyModuleDef *module, Py double lfactor; double rfactor; - if (!PyArg_ParseTuple(args, "y*idd:tostereo", + if (!PyArg_ParseStack(stack, nargs, "y*idd:tostereo", &fragment, &width, &lfactor, &rfactor)) goto exit; + if (!_PyArg_NoKeywords("tostereo()", kwargs)) + goto exit; return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor); exit: @@ -476,23 +504,25 @@ PyDoc_STRVAR(audioop_add__doc__, "Return a fragment which is the addition of the two samples passed as parameters."); #define AUDIOOP_ADD_METHODDEF \ - {"add", (PyCFunction)audioop_add, METH_VARARGS, audioop_add__doc__}, + {"add", (PyCFunction)audioop_add, METH_FASTCALL, audioop_add__doc__}, static PyObject * audioop_add_impl(PyModuleDef *module, Py_buffer *fragment1, Py_buffer *fragment2, int width); static PyObject * -audioop_add(PyModuleDef *module, PyObject *args) +audioop_add(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment1 = {NULL, NULL}; Py_buffer fragment2 = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*y*i:add", + if (!PyArg_ParseStack(stack, nargs, "y*y*i:add", &fragment1, &fragment2, &width)) goto exit; + if (!_PyArg_NoKeywords("add()", kwargs)) + goto exit; return_value = audioop_add_impl(module, &fragment1, &fragment2, width); exit: @@ -513,23 +543,25 @@ PyDoc_STRVAR(audioop_bias__doc__, "Return a fragment that is the original fragment with a bias added to each sample."); #define AUDIOOP_BIAS_METHODDEF \ - {"bias", (PyCFunction)audioop_bias, METH_VARARGS, audioop_bias__doc__}, + {"bias", (PyCFunction)audioop_bias, METH_FASTCALL, audioop_bias__doc__}, static PyObject * audioop_bias_impl(PyModuleDef *module, Py_buffer *fragment, int width, int bias); static PyObject * -audioop_bias(PyModuleDef *module, PyObject *args) +audioop_bias(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; int bias; - if (!PyArg_ParseTuple(args, "y*ii:bias", + if (!PyArg_ParseStack(stack, nargs, "y*ii:bias", &fragment, &width, &bias)) goto exit; + if (!_PyArg_NoKeywords("bias()", kwargs)) + goto exit; return_value = audioop_bias_impl(module, &fragment, width, bias); exit: @@ -547,21 +579,23 @@ PyDoc_STRVAR(audioop_reverse__doc__, "Reverse the samples in a fragment and returns the modified fragment."); #define AUDIOOP_REVERSE_METHODDEF \ - {"reverse", (PyCFunction)audioop_reverse, METH_VARARGS, audioop_reverse__doc__}, + {"reverse", (PyCFunction)audioop_reverse, METH_FASTCALL, audioop_reverse__doc__}, static PyObject * audioop_reverse_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_reverse(PyModuleDef *module, PyObject *args) +audioop_reverse(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:reverse", + if (!PyArg_ParseStack(stack, nargs, "y*i:reverse", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("reverse()", kwargs)) + goto exit; return_value = audioop_reverse_impl(module, &fragment, width); exit: @@ -579,21 +613,23 @@ PyDoc_STRVAR(audioop_byteswap__doc__, "Convert big-endian samples to little-endian and vice versa."); #define AUDIOOP_BYTESWAP_METHODDEF \ - {"byteswap", (PyCFunction)audioop_byteswap, METH_VARARGS, audioop_byteswap__doc__}, + {"byteswap", (PyCFunction)audioop_byteswap, METH_FASTCALL, audioop_byteswap__doc__}, static PyObject * audioop_byteswap_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_byteswap(PyModuleDef *module, PyObject *args) +audioop_byteswap(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:byteswap", + if (!PyArg_ParseStack(stack, nargs, "y*i:byteswap", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("byteswap()", kwargs)) + goto exit; return_value = audioop_byteswap_impl(module, &fragment, width); exit: @@ -611,23 +647,25 @@ PyDoc_STRVAR(audioop_lin2lin__doc__, "Convert samples between 1-, 2-, 3- and 4-byte formats."); #define AUDIOOP_LIN2LIN_METHODDEF \ - {"lin2lin", (PyCFunction)audioop_lin2lin, METH_VARARGS, audioop_lin2lin__doc__}, + {"lin2lin", (PyCFunction)audioop_lin2lin, METH_FASTCALL, audioop_lin2lin__doc__}, static PyObject * audioop_lin2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width, int newwidth); static PyObject * -audioop_lin2lin(PyModuleDef *module, PyObject *args) +audioop_lin2lin(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; int newwidth; - if (!PyArg_ParseTuple(args, "y*ii:lin2lin", + if (!PyArg_ParseStack(stack, nargs, "y*ii:lin2lin", &fragment, &width, &newwidth)) goto exit; + if (!_PyArg_NoKeywords("lin2lin()", kwargs)) + goto exit; return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth); exit: @@ -646,7 +684,7 @@ PyDoc_STRVAR(audioop_ratecv__doc__, "Convert the frame rate of the input fragment."); #define AUDIOOP_RATECV_METHODDEF \ - {"ratecv", (PyCFunction)audioop_ratecv, METH_VARARGS, audioop_ratecv__doc__}, + {"ratecv", (PyCFunction)audioop_ratecv, METH_FASTCALL, audioop_ratecv__doc__}, static PyObject * audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width, @@ -654,7 +692,7 @@ audioop_ratecv_impl(PyModuleDef *module, int weightA, int weightB); static PyObject * -audioop_ratecv(PyModuleDef *module, PyObject *args) +audioop_ratecv(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; @@ -666,9 +704,11 @@ audioop_ratecv(PyModuleDef *module, PyOb int weightA = 1; int weightB = 0; - if (!PyArg_ParseTuple(args, "y*iiiiO|ii:ratecv", + if (!PyArg_ParseStack(stack, nargs, "y*iiiiO|ii:ratecv", &fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB)) goto exit; + if (!_PyArg_NoKeywords("ratecv()", kwargs)) + goto exit; return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB); exit: @@ -686,21 +726,23 @@ PyDoc_STRVAR(audioop_lin2ulaw__doc__, "Convert samples in the audio fragment to u-LAW encoding."); #define AUDIOOP_LIN2ULAW_METHODDEF \ - {"lin2ulaw", (PyCFunction)audioop_lin2ulaw, METH_VARARGS, audioop_lin2ulaw__doc__}, + {"lin2ulaw", (PyCFunction)audioop_lin2ulaw, METH_FASTCALL, audioop_lin2ulaw__doc__}, static PyObject * audioop_lin2ulaw_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_lin2ulaw(PyModuleDef *module, PyObject *args) +audioop_lin2ulaw(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:lin2ulaw", + if (!PyArg_ParseStack(stack, nargs, "y*i:lin2ulaw", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("lin2ulaw()", kwargs)) + goto exit; return_value = audioop_lin2ulaw_impl(module, &fragment, width); exit: @@ -718,21 +760,23 @@ PyDoc_STRVAR(audioop_ulaw2lin__doc__, "Convert sound fragments in u-LAW encoding to linearly encoded sound fragments."); #define AUDIOOP_ULAW2LIN_METHODDEF \ - {"ulaw2lin", (PyCFunction)audioop_ulaw2lin, METH_VARARGS, audioop_ulaw2lin__doc__}, + {"ulaw2lin", (PyCFunction)audioop_ulaw2lin, METH_FASTCALL, audioop_ulaw2lin__doc__}, static PyObject * audioop_ulaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_ulaw2lin(PyModuleDef *module, PyObject *args) +audioop_ulaw2lin(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:ulaw2lin", + if (!PyArg_ParseStack(stack, nargs, "y*i:ulaw2lin", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("ulaw2lin()", kwargs)) + goto exit; return_value = audioop_ulaw2lin_impl(module, &fragment, width); exit: @@ -750,21 +794,23 @@ PyDoc_STRVAR(audioop_lin2alaw__doc__, "Convert samples in the audio fragment to a-LAW encoding."); #define AUDIOOP_LIN2ALAW_METHODDEF \ - {"lin2alaw", (PyCFunction)audioop_lin2alaw, METH_VARARGS, audioop_lin2alaw__doc__}, + {"lin2alaw", (PyCFunction)audioop_lin2alaw, METH_FASTCALL, audioop_lin2alaw__doc__}, static PyObject * audioop_lin2alaw_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_lin2alaw(PyModuleDef *module, PyObject *args) +audioop_lin2alaw(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:lin2alaw", + if (!PyArg_ParseStack(stack, nargs, "y*i:lin2alaw", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("lin2alaw()", kwargs)) + goto exit; return_value = audioop_lin2alaw_impl(module, &fragment, width); exit: @@ -782,21 +828,23 @@ PyDoc_STRVAR(audioop_alaw2lin__doc__, "Convert sound fragments in a-LAW encoding to linearly encoded sound fragments."); #define AUDIOOP_ALAW2LIN_METHODDEF \ - {"alaw2lin", (PyCFunction)audioop_alaw2lin, METH_VARARGS, audioop_alaw2lin__doc__}, + {"alaw2lin", (PyCFunction)audioop_alaw2lin, METH_FASTCALL, audioop_alaw2lin__doc__}, static PyObject * audioop_alaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width); static PyObject * -audioop_alaw2lin(PyModuleDef *module, PyObject *args) +audioop_alaw2lin(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; - if (!PyArg_ParseTuple(args, "y*i:alaw2lin", + if (!PyArg_ParseStack(stack, nargs, "y*i:alaw2lin", &fragment, &width)) goto exit; + if (!_PyArg_NoKeywords("alaw2lin()", kwargs)) + goto exit; return_value = audioop_alaw2lin_impl(module, &fragment, width); exit: @@ -814,23 +862,25 @@ PyDoc_STRVAR(audioop_lin2adpcm__doc__, "Convert samples to 4 bit Intel/DVI ADPCM encoding."); #define AUDIOOP_LIN2ADPCM_METHODDEF \ - {"lin2adpcm", (PyCFunction)audioop_lin2adpcm, METH_VARARGS, audioop_lin2adpcm__doc__}, + {"lin2adpcm", (PyCFunction)audioop_lin2adpcm, METH_FASTCALL, audioop_lin2adpcm__doc__}, static PyObject * audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width, PyObject *state); static PyObject * -audioop_lin2adpcm(PyModuleDef *module, PyObject *args) +audioop_lin2adpcm(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; PyObject *state; - if (!PyArg_ParseTuple(args, "y*iO:lin2adpcm", + if (!PyArg_ParseStack(stack, nargs, "y*iO:lin2adpcm", &fragment, &width, &state)) goto exit; + if (!_PyArg_NoKeywords("lin2adpcm()", kwargs)) + goto exit; return_value = audioop_lin2adpcm_impl(module, &fragment, width, state); exit: @@ -848,23 +898,25 @@ PyDoc_STRVAR(audioop_adpcm2lin__doc__, "Decode an Intel/DVI ADPCM coded fragment to a linear fragment."); #define AUDIOOP_ADPCM2LIN_METHODDEF \ - {"adpcm2lin", (PyCFunction)audioop_adpcm2lin, METH_VARARGS, audioop_adpcm2lin__doc__}, + {"adpcm2lin", (PyCFunction)audioop_adpcm2lin, METH_FASTCALL, audioop_adpcm2lin__doc__}, static PyObject * audioop_adpcm2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width, PyObject *state); static PyObject * -audioop_adpcm2lin(PyModuleDef *module, PyObject *args) +audioop_adpcm2lin(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer fragment = {NULL, NULL}; int width; PyObject *state; - if (!PyArg_ParseTuple(args, "y*iO:adpcm2lin", + if (!PyArg_ParseStack(stack, nargs, "y*iO:adpcm2lin", &fragment, &width, &state)) goto exit; + if (!_PyArg_NoKeywords("adpcm2lin()", kwargs)) + goto exit; return_value = audioop_adpcm2lin_impl(module, &fragment, width, state); exit: @@ -874,4 +926,4 @@ exit: return return_value; } -/*[clinic end generated code: output=a076e1b213a8727b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1703cedabb0dc5e0 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/binascii.c.h --- a/Modules/clinic/binascii.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/binascii.c.h Thu May 19 13:47:42 2016 +0200 @@ -99,20 +99,20 @@ PyDoc_STRVAR(binascii_b2a_base64__doc__, "Base64-code line of data."); #define BINASCII_B2A_BASE64_METHODDEF \ - {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_VARARGS|METH_KEYWORDS, binascii_b2a_base64__doc__}, + {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_FASTCALL, binascii_b2a_base64__doc__}, static PyObject * binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline); static PyObject * -binascii_b2a_base64(PyModuleDef *module, PyObject *args, PyObject *kwargs) +binascii_b2a_base64(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "newline", NULL}; Py_buffer data = {NULL, NULL}; int newline = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|$i:b2a_base64", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|$i:b2a_base64", _keywords, &data, &newline)) goto exit; return_value = binascii_b2a_base64_impl(module, &data, newline); @@ -252,22 +252,24 @@ PyDoc_STRVAR(binascii_crc_hqx__doc__, "Compute hqx CRC incrementally."); #define BINASCII_CRC_HQX_METHODDEF \ - {"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_VARARGS, binascii_crc_hqx__doc__}, + {"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_FASTCALL, binascii_crc_hqx__doc__}, static unsigned int binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc); static PyObject * -binascii_crc_hqx(PyModuleDef *module, PyObject *args) +binascii_crc_hqx(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; unsigned int crc; unsigned int _return_value; - if (!PyArg_ParseTuple(args, "y*I:crc_hqx", + if (!PyArg_ParseStack(stack, nargs, "y*I:crc_hqx", &data, &crc)) goto exit; + if (!_PyArg_NoKeywords("crc_hqx()", kwargs)) + goto exit; _return_value = binascii_crc_hqx_impl(module, &data, crc); if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) goto exit; @@ -288,22 +290,24 @@ PyDoc_STRVAR(binascii_crc32__doc__, "Compute CRC-32 incrementally."); #define BINASCII_CRC32_METHODDEF \ - {"crc32", (PyCFunction)binascii_crc32, METH_VARARGS, binascii_crc32__doc__}, + {"crc32", (PyCFunction)binascii_crc32, METH_FASTCALL, binascii_crc32__doc__}, static unsigned int binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc); static PyObject * -binascii_crc32(PyModuleDef *module, PyObject *args) +binascii_crc32(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; unsigned int crc = 0; unsigned int _return_value; - if (!PyArg_ParseTuple(args, "y*|I:crc32", + if (!PyArg_ParseStack(stack, nargs, "y*|I:crc32", &data, &crc)) goto exit; + if (!_PyArg_NoKeywords("crc32()", kwargs)) + goto exit; _return_value = binascii_crc32_impl(module, &data, crc); if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) goto exit; @@ -454,20 +458,20 @@ PyDoc_STRVAR(binascii_a2b_qp__doc__, "Decode a string of qp-encoded data."); #define BINASCII_A2B_QP_METHODDEF \ - {"a2b_qp", (PyCFunction)binascii_a2b_qp, METH_VARARGS|METH_KEYWORDS, binascii_a2b_qp__doc__}, + {"a2b_qp", (PyCFunction)binascii_a2b_qp, METH_FASTCALL, binascii_a2b_qp__doc__}, static PyObject * binascii_a2b_qp_impl(PyModuleDef *module, Py_buffer *data, int header); static PyObject * -binascii_a2b_qp(PyModuleDef *module, PyObject *args, PyObject *kwargs) +binascii_a2b_qp(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "header", NULL}; Py_buffer data = {NULL, NULL}; int header = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i:a2b_qp", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|i:a2b_qp", _keywords, ascii_buffer_converter, &data, &header)) goto exit; return_value = binascii_a2b_qp_impl(module, &data, header); @@ -491,14 +495,14 @@ PyDoc_STRVAR(binascii_b2a_qp__doc__, "are both encoded. When quotetabs is set, space and tabs are encoded."); #define BINASCII_B2A_QP_METHODDEF \ - {"b2a_qp", (PyCFunction)binascii_b2a_qp, METH_VARARGS|METH_KEYWORDS, binascii_b2a_qp__doc__}, + {"b2a_qp", (PyCFunction)binascii_b2a_qp, METH_FASTCALL, binascii_b2a_qp__doc__}, static PyObject * binascii_b2a_qp_impl(PyModuleDef *module, Py_buffer *data, int quotetabs, int istext, int header); static PyObject * -binascii_b2a_qp(PyModuleDef *module, PyObject *args, PyObject *kwargs) +binascii_b2a_qp(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "quotetabs", "istext", "header", NULL}; @@ -507,7 +511,7 @@ binascii_b2a_qp(PyModuleDef *module, PyO int istext = 1; int header = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|iii:b2a_qp", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|iii:b2a_qp", _keywords, &data, "etabs, &istext, &header)) goto exit; return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header); @@ -519,4 +523,4 @@ exit: return return_value; } -/*[clinic end generated code: output=b15a24350d105251 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e0d5033a99fbb3d4 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/cmathmodule.c.h --- a/Modules/clinic/cmathmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/cmathmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -626,21 +626,23 @@ PyDoc_STRVAR(cmath_log__doc__, "If the base not specified, returns the natural logarithm (base e) of z."); #define CMATH_LOG_METHODDEF \ - {"log", (PyCFunction)cmath_log, METH_VARARGS, cmath_log__doc__}, + {"log", (PyCFunction)cmath_log, METH_FASTCALL, cmath_log__doc__}, static PyObject * cmath_log_impl(PyModuleDef *module, Py_complex x, PyObject *y_obj); static PyObject * -cmath_log(PyModuleDef *module, PyObject *args) +cmath_log(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_complex x; PyObject *y_obj = NULL; - if (!PyArg_ParseTuple(args, "D|O:log", + if (!PyArg_ParseStack(stack, nargs, "D|O:log", &x, &y_obj)) goto exit; + if (!_PyArg_NoKeywords("log()", kwargs)) + goto exit; return_value = cmath_log_impl(module, x, y_obj); exit: @@ -708,21 +710,23 @@ PyDoc_STRVAR(cmath_rect__doc__, "Convert from polar coordinates to rectangular coordinates."); #define CMATH_RECT_METHODDEF \ - {"rect", (PyCFunction)cmath_rect, METH_VARARGS, cmath_rect__doc__}, + {"rect", (PyCFunction)cmath_rect, METH_FASTCALL, cmath_rect__doc__}, static PyObject * cmath_rect_impl(PyModuleDef *module, double r, double phi); static PyObject * -cmath_rect(PyModuleDef *module, PyObject *args) +cmath_rect(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; double r; double phi; - if (!PyArg_ParseTuple(args, "dd:rect", + if (!PyArg_ParseStack(stack, nargs, "dd:rect", &r, &phi)) goto exit; + if (!_PyArg_NoKeywords("rect()", kwargs)) + goto exit; return_value = cmath_rect_impl(module, r, phi); exit: @@ -829,14 +833,14 @@ PyDoc_STRVAR(cmath_isclose__doc__, "not close to anything, even itself. inf and -inf are only close to themselves."); #define CMATH_ISCLOSE_METHODDEF \ - {"isclose", (PyCFunction)cmath_isclose, METH_VARARGS|METH_KEYWORDS, cmath_isclose__doc__}, + {"isclose", (PyCFunction)cmath_isclose, METH_FASTCALL, cmath_isclose__doc__}, static int cmath_isclose_impl(PyModuleDef *module, Py_complex a, Py_complex b, double rel_tol, double abs_tol); static PyObject * -cmath_isclose(PyModuleDef *module, PyObject *args, PyObject *kwargs) +cmath_isclose(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL}; @@ -846,7 +850,7 @@ cmath_isclose(PyModuleDef *module, PyObj double abs_tol = 0.0; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "DD|$dd:isclose", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "DD|$dd:isclose", _keywords, &a, &b, &rel_tol, &abs_tol)) goto exit; _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol); @@ -857,4 +861,4 @@ cmath_isclose(PyModuleDef *module, PyObj exit: return return_value; } -/*[clinic end generated code: output=229e9c48c9d27362 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cc4c5a31795b0343 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/fcntlmodule.c.h --- a/Modules/clinic/fcntlmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/fcntlmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -19,22 +19,24 @@ PyDoc_STRVAR(fcntl_fcntl__doc__, "corresponding to the return value of the fcntl call in the C code."); #define FCNTL_FCNTL_METHODDEF \ - {"fcntl", (PyCFunction)fcntl_fcntl, METH_VARARGS, fcntl_fcntl__doc__}, + {"fcntl", (PyCFunction)fcntl_fcntl, METH_FASTCALL, fcntl_fcntl__doc__}, static PyObject * fcntl_fcntl_impl(PyModuleDef *module, int fd, int code, PyObject *arg); static PyObject * -fcntl_fcntl(PyModuleDef *module, PyObject *args) +fcntl_fcntl(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int code; PyObject *arg = NULL; - if (!PyArg_ParseTuple(args, "O&i|O:fcntl", + if (!PyArg_ParseStack(stack, nargs, "O&i|O:fcntl", conv_descriptor, &fd, &code, &arg)) goto exit; + if (!_PyArg_NoKeywords("fcntl()", kwargs)) + goto exit; return_value = fcntl_fcntl_impl(module, fd, code, arg); exit: @@ -75,14 +77,14 @@ PyDoc_STRVAR(fcntl_ioctl__doc__, "code."); #define FCNTL_IOCTL_METHODDEF \ - {"ioctl", (PyCFunction)fcntl_ioctl, METH_VARARGS, fcntl_ioctl__doc__}, + {"ioctl", (PyCFunction)fcntl_ioctl, METH_FASTCALL, fcntl_ioctl__doc__}, static PyObject * fcntl_ioctl_impl(PyModuleDef *module, int fd, unsigned int code, PyObject *ob_arg, int mutate_arg); static PyObject * -fcntl_ioctl(PyModuleDef *module, PyObject *args) +fcntl_ioctl(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; @@ -90,9 +92,11 @@ fcntl_ioctl(PyModuleDef *module, PyObjec PyObject *ob_arg = NULL; int mutate_arg = 1; - if (!PyArg_ParseTuple(args, "O&I|Op:ioctl", + if (!PyArg_ParseStack(stack, nargs, "O&I|Op:ioctl", conv_descriptor, &fd, &code, &ob_arg, &mutate_arg)) goto exit; + if (!_PyArg_NoKeywords("ioctl()", kwargs)) + goto exit; return_value = fcntl_ioctl_impl(module, fd, code, ob_arg, mutate_arg); exit: @@ -109,21 +113,23 @@ PyDoc_STRVAR(fcntl_flock__doc__, "function is emulated using fcntl())."); #define FCNTL_FLOCK_METHODDEF \ - {"flock", (PyCFunction)fcntl_flock, METH_VARARGS, fcntl_flock__doc__}, + {"flock", (PyCFunction)fcntl_flock, METH_FASTCALL, fcntl_flock__doc__}, static PyObject * fcntl_flock_impl(PyModuleDef *module, int fd, int code); static PyObject * -fcntl_flock(PyModuleDef *module, PyObject *args) +fcntl_flock(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int code; - if (!PyArg_ParseTuple(args, "O&i:flock", + if (!PyArg_ParseStack(stack, nargs, "O&i:flock", conv_descriptor, &fd, &code)) goto exit; + if (!_PyArg_NoKeywords("flock()", kwargs)) + goto exit; return_value = fcntl_flock_impl(module, fd, code); exit: @@ -158,14 +164,14 @@ PyDoc_STRVAR(fcntl_lockf__doc__, " 2 - relative to the end of the file (SEEK_END)"); #define FCNTL_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)fcntl_lockf, METH_VARARGS, fcntl_lockf__doc__}, + {"lockf", (PyCFunction)fcntl_lockf, METH_FASTCALL, fcntl_lockf__doc__}, static PyObject * fcntl_lockf_impl(PyModuleDef *module, int fd, int code, PyObject *lenobj, PyObject *startobj, int whence); static PyObject * -fcntl_lockf(PyModuleDef *module, PyObject *args) +fcntl_lockf(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; @@ -174,12 +180,14 @@ fcntl_lockf(PyModuleDef *module, PyObjec PyObject *startobj = NULL; int whence = 0; - if (!PyArg_ParseTuple(args, "O&i|OOi:lockf", + if (!PyArg_ParseStack(stack, nargs, "O&i|OOi:lockf", conv_descriptor, &fd, &code, &lenobj, &startobj, &whence)) goto exit; + if (!_PyArg_NoKeywords("lockf()", kwargs)) + goto exit; return_value = fcntl_lockf_impl(module, fd, code, lenobj, startobj, whence); exit: return return_value; } -/*[clinic end generated code: output=b7d6e8fc2ad09c48 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7e16aab42e81ce13 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/grpmodule.c.h --- a/Modules/clinic/grpmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/grpmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -11,19 +11,19 @@ PyDoc_STRVAR(grp_getgrgid__doc__, "If id is not valid, raise KeyError."); #define GRP_GETGRGID_METHODDEF \ - {"getgrgid", (PyCFunction)grp_getgrgid, METH_VARARGS|METH_KEYWORDS, grp_getgrgid__doc__}, + {"getgrgid", (PyCFunction)grp_getgrgid, METH_FASTCALL, grp_getgrgid__doc__}, static PyObject * grp_getgrgid_impl(PyModuleDef *module, PyObject *id); static PyObject * -grp_getgrgid(PyModuleDef *module, PyObject *args, PyObject *kwargs) +grp_getgrgid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"id", NULL}; PyObject *id; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:getgrgid", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O:getgrgid", _keywords, &id)) goto exit; return_value = grp_getgrgid_impl(module, id); @@ -41,19 +41,19 @@ PyDoc_STRVAR(grp_getgrnam__doc__, "If name is not valid, raise KeyError."); #define GRP_GETGRNAM_METHODDEF \ - {"getgrnam", (PyCFunction)grp_getgrnam, METH_VARARGS|METH_KEYWORDS, grp_getgrnam__doc__}, + {"getgrnam", (PyCFunction)grp_getgrnam, METH_FASTCALL, grp_getgrnam__doc__}, static PyObject * grp_getgrnam_impl(PyModuleDef *module, PyObject *name); static PyObject * -grp_getgrnam(PyModuleDef *module, PyObject *args, PyObject *kwargs) +grp_getgrnam(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"name", NULL}; PyObject *name; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "U:getgrnam", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "U:getgrnam", _keywords, &name)) goto exit; return_value = grp_getgrnam_impl(module, name); @@ -82,4 +82,4 @@ grp_getgrall(PyModuleDef *module, PyObje { return grp_getgrall_impl(module); } -/*[clinic end generated code: output=5191c25600afb1bd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9aeda11b50f4ea5c input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/md5module.c.h --- a/Modules/clinic/md5module.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/md5module.c.h Thu May 19 13:47:42 2016 +0200 @@ -72,19 +72,19 @@ PyDoc_STRVAR(_md5_md5__doc__, "Return a new MD5 hash object; optionally initialized with a string."); #define _MD5_MD5_METHODDEF \ - {"md5", (PyCFunction)_md5_md5, METH_VARARGS|METH_KEYWORDS, _md5_md5__doc__}, + {"md5", (PyCFunction)_md5_md5, METH_FASTCALL, _md5_md5__doc__}, static PyObject * _md5_md5_impl(PyModuleDef *module, PyObject *string); static PyObject * -_md5_md5(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_md5_md5(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", NULL}; PyObject *string = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:md5", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:md5", _keywords, &string)) goto exit; return_value = _md5_md5_impl(module, string); @@ -92,4 +92,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=0f803ded701aca54 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7ea8c3d1fc9ac698 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/posixmodule.c.h --- a/Modules/clinic/posixmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/posixmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -27,14 +27,14 @@ PyDoc_STRVAR(os_stat__doc__, " an open file descriptor."); #define OS_STAT_METHODDEF \ - {"stat", (PyCFunction)os_stat, METH_VARARGS|METH_KEYWORDS, os_stat__doc__}, + {"stat", (PyCFunction)os_stat, METH_FASTCALL, os_stat__doc__}, static PyObject * os_stat_impl(PyModuleDef *module, path_t *path, int dir_fd, int follow_symlinks); static PyObject * -os_stat(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_stat(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; @@ -42,7 +42,7 @@ os_stat(PyModuleDef *module, PyObject *a int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&p:stat", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|$O&p:stat", _keywords, path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) goto exit; return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); @@ -64,20 +64,20 @@ PyDoc_STRVAR(os_lstat__doc__, "Equivalent to stat(path, follow_symlinks=False)."); #define OS_LSTAT_METHODDEF \ - {"lstat", (PyCFunction)os_lstat, METH_VARARGS|METH_KEYWORDS, os_lstat__doc__}, + {"lstat", (PyCFunction)os_lstat, METH_FASTCALL, os_lstat__doc__}, static PyObject * os_lstat_impl(PyModuleDef *module, path_t *path, int dir_fd); static PyObject * -os_lstat(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_lstat(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "dir_fd", NULL}; path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:lstat", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|$O&:lstat", _keywords, path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_lstat_impl(module, &path, dir_fd); @@ -122,14 +122,14 @@ PyDoc_STRVAR(os_access__doc__, " has the specified access to the path."); #define OS_ACCESS_METHODDEF \ - {"access", (PyCFunction)os_access, METH_VARARGS|METH_KEYWORDS, os_access__doc__}, + {"access", (PyCFunction)os_access, METH_FASTCALL, os_access__doc__}, static int os_access_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks); static PyObject * -os_access(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_access(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; @@ -140,7 +140,7 @@ os_access(PyModuleDef *module, PyObject int follow_symlinks = 1; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i|$O&pp:access", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&i|$O&pp:access", _keywords, path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks)) goto exit; _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); @@ -225,19 +225,19 @@ PyDoc_STRVAR(os_chdir__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_CHDIR_METHODDEF \ - {"chdir", (PyCFunction)os_chdir, METH_VARARGS|METH_KEYWORDS, os_chdir__doc__}, + {"chdir", (PyCFunction)os_chdir, METH_FASTCALL, os_chdir__doc__}, static PyObject * os_chdir_impl(PyModuleDef *module, path_t *path); static PyObject * -os_chdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_chdir(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", NULL}; path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:chdir", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:chdir", _keywords, path_converter, &path)) goto exit; return_value = os_chdir_impl(module, &path); @@ -261,19 +261,19 @@ PyDoc_STRVAR(os_fchdir__doc__, "Equivalent to os.chdir(fd)."); #define OS_FCHDIR_METHODDEF \ - {"fchdir", (PyCFunction)os_fchdir, METH_VARARGS|METH_KEYWORDS, os_fchdir__doc__}, + {"fchdir", (PyCFunction)os_fchdir, METH_FASTCALL, os_fchdir__doc__}, static PyObject * os_fchdir_impl(PyModuleDef *module, int fd); static PyObject * -os_fchdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_fchdir(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", NULL}; int fd; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:fchdir", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:fchdir", _keywords, fildes_converter, &fd)) goto exit; return_value = os_fchdir_impl(module, fd); @@ -311,14 +311,14 @@ PyDoc_STRVAR(os_chmod__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_CHMOD_METHODDEF \ - {"chmod", (PyCFunction)os_chmod, METH_VARARGS|METH_KEYWORDS, os_chmod__doc__}, + {"chmod", (PyCFunction)os_chmod, METH_FASTCALL, os_chmod__doc__}, static PyObject * os_chmod_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int follow_symlinks); static PyObject * -os_chmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_chmod(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; @@ -327,7 +327,7 @@ os_chmod(PyModuleDef *module, PyObject * int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i|$O&p:chmod", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&i|$O&p:chmod", _keywords, path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) goto exit; return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); @@ -350,20 +350,20 @@ PyDoc_STRVAR(os_fchmod__doc__, "Equivalent to os.chmod(fd, mode)."); #define OS_FCHMOD_METHODDEF \ - {"fchmod", (PyCFunction)os_fchmod, METH_VARARGS|METH_KEYWORDS, os_fchmod__doc__}, + {"fchmod", (PyCFunction)os_fchmod, METH_FASTCALL, os_fchmod__doc__}, static PyObject * os_fchmod_impl(PyModuleDef *module, int fd, int mode); static PyObject * -os_fchmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_fchmod(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", "mode", NULL}; int fd; int mode; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:fchmod", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "ii:fchmod", _keywords, &fd, &mode)) goto exit; return_value = os_fchmod_impl(module, fd, mode); @@ -386,20 +386,20 @@ PyDoc_STRVAR(os_lchmod__doc__, "Equivalent to chmod(path, mode, follow_symlinks=False).\""); #define OS_LCHMOD_METHODDEF \ - {"lchmod", (PyCFunction)os_lchmod, METH_VARARGS|METH_KEYWORDS, os_lchmod__doc__}, + {"lchmod", (PyCFunction)os_lchmod, METH_FASTCALL, os_lchmod__doc__}, static PyObject * os_lchmod_impl(PyModuleDef *module, path_t *path, int mode); static PyObject * -os_lchmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_lchmod(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "mode", NULL}; path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0); int mode; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i:lchmod", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&i:lchmod", _keywords, path_converter, &path, &mode)) goto exit; return_value = os_lchmod_impl(module, &path, mode); @@ -428,14 +428,14 @@ PyDoc_STRVAR(os_chflags__doc__, "unavailable, using it will raise a NotImplementedError."); #define OS_CHFLAGS_METHODDEF \ - {"chflags", (PyCFunction)os_chflags, METH_VARARGS|METH_KEYWORDS, os_chflags__doc__}, + {"chflags", (PyCFunction)os_chflags, METH_FASTCALL, os_chflags__doc__}, static PyObject * os_chflags_impl(PyModuleDef *module, path_t *path, unsigned long flags, int follow_symlinks); static PyObject * -os_chflags(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_chflags(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "flags", "follow_symlinks", NULL}; @@ -443,7 +443,7 @@ os_chflags(PyModuleDef *module, PyObject unsigned long flags; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k|p:chflags", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&k|p:chflags", _keywords, path_converter, &path, &flags, &follow_symlinks)) goto exit; return_value = os_chflags_impl(module, &path, flags, follow_symlinks); @@ -469,20 +469,20 @@ PyDoc_STRVAR(os_lchflags__doc__, "Equivalent to chflags(path, flags, follow_symlinks=False)."); #define OS_LCHFLAGS_METHODDEF \ - {"lchflags", (PyCFunction)os_lchflags, METH_VARARGS|METH_KEYWORDS, os_lchflags__doc__}, + {"lchflags", (PyCFunction)os_lchflags, METH_FASTCALL, os_lchflags__doc__}, static PyObject * os_lchflags_impl(PyModuleDef *module, path_t *path, unsigned long flags); static PyObject * -os_lchflags(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_lchflags(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "flags", NULL}; path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0); unsigned long flags; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k:lchflags", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&k:lchflags", _keywords, path_converter, &path, &flags)) goto exit; return_value = os_lchflags_impl(module, &path, flags); @@ -505,19 +505,19 @@ PyDoc_STRVAR(os_chroot__doc__, "Change root directory to path."); #define OS_CHROOT_METHODDEF \ - {"chroot", (PyCFunction)os_chroot, METH_VARARGS|METH_KEYWORDS, os_chroot__doc__}, + {"chroot", (PyCFunction)os_chroot, METH_FASTCALL, os_chroot__doc__}, static PyObject * os_chroot_impl(PyModuleDef *module, path_t *path); static PyObject * -os_chroot(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_chroot(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", NULL}; path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:chroot", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:chroot", _keywords, path_converter, &path)) goto exit; return_value = os_chroot_impl(module, &path); @@ -540,19 +540,19 @@ PyDoc_STRVAR(os_fsync__doc__, "Force write of fd to disk."); #define OS_FSYNC_METHODDEF \ - {"fsync", (PyCFunction)os_fsync, METH_VARARGS|METH_KEYWORDS, os_fsync__doc__}, + {"fsync", (PyCFunction)os_fsync, METH_FASTCALL, os_fsync__doc__}, static PyObject * os_fsync_impl(PyModuleDef *module, int fd); static PyObject * -os_fsync(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_fsync(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", NULL}; int fd; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:fsync", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:fsync", _keywords, fildes_converter, &fd)) goto exit; return_value = os_fsync_impl(module, fd); @@ -594,19 +594,19 @@ PyDoc_STRVAR(os_fdatasync__doc__, "Force write of fd to disk without forcing update of metadata."); #define OS_FDATASYNC_METHODDEF \ - {"fdatasync", (PyCFunction)os_fdatasync, METH_VARARGS|METH_KEYWORDS, os_fdatasync__doc__}, + {"fdatasync", (PyCFunction)os_fdatasync, METH_FASTCALL, os_fdatasync__doc__}, static PyObject * os_fdatasync_impl(PyModuleDef *module, int fd); static PyObject * -os_fdatasync(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_fdatasync(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", NULL}; int fd; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:fdatasync", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:fdatasync", _keywords, fildes_converter, &fd)) goto exit; return_value = os_fdatasync_impl(module, fd); @@ -650,14 +650,14 @@ PyDoc_STRVAR(os_chown__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_CHOWN_METHODDEF \ - {"chown", (PyCFunction)os_chown, METH_VARARGS|METH_KEYWORDS, os_chown__doc__}, + {"chown", (PyCFunction)os_chown, METH_FASTCALL, os_chown__doc__}, static PyObject * os_chown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid, int dir_fd, int follow_symlinks); static PyObject * -os_chown(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_chown(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; @@ -667,7 +667,7 @@ os_chown(PyModuleDef *module, PyObject * int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&O&|$O&p:chown", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&O&|$O&p:chown", _keywords, path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) goto exit; return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); @@ -692,13 +692,13 @@ PyDoc_STRVAR(os_fchown__doc__, "Equivalent to os.chown(fd, uid, gid)."); #define OS_FCHOWN_METHODDEF \ - {"fchown", (PyCFunction)os_fchown, METH_VARARGS|METH_KEYWORDS, os_fchown__doc__}, + {"fchown", (PyCFunction)os_fchown, METH_FASTCALL, os_fchown__doc__}, static PyObject * os_fchown_impl(PyModuleDef *module, int fd, uid_t uid, gid_t gid); static PyObject * -os_fchown(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_fchown(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", "uid", "gid", NULL}; @@ -706,7 +706,7 @@ os_fchown(PyModuleDef *module, PyObject uid_t uid; gid_t gid; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO&O&:fchown", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "iO&O&:fchown", _keywords, &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) goto exit; return_value = os_fchown_impl(module, fd, uid, gid); @@ -729,13 +729,13 @@ PyDoc_STRVAR(os_lchown__doc__, "Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); #define OS_LCHOWN_METHODDEF \ - {"lchown", (PyCFunction)os_lchown, METH_VARARGS|METH_KEYWORDS, os_lchown__doc__}, + {"lchown", (PyCFunction)os_lchown, METH_FASTCALL, os_lchown__doc__}, static PyObject * os_lchown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid); static PyObject * -os_lchown(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_lchown(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "uid", "gid", NULL}; @@ -743,7 +743,7 @@ os_lchown(PyModuleDef *module, PyObject uid_t uid; gid_t gid; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&O&:lchown", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&O&:lchown", _keywords, path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) goto exit; return_value = os_lchown_impl(module, &path, uid, gid); @@ -813,14 +813,14 @@ PyDoc_STRVAR(os_link__doc__, " NotImplementedError."); #define OS_LINK_METHODDEF \ - {"link", (PyCFunction)os_link, METH_VARARGS|METH_KEYWORDS, os_link__doc__}, + {"link", (PyCFunction)os_link, METH_FASTCALL, os_link__doc__}, static PyObject * os_link_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int follow_symlinks); static PyObject * -os_link(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_link(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; @@ -830,7 +830,7 @@ os_link(PyModuleDef *module, PyObject *a int dst_dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$O&O&p:link", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&|$O&O&p:link", _keywords, path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks)) goto exit; return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); @@ -864,19 +864,19 @@ PyDoc_STRVAR(os_listdir__doc__, "entries \'.\' and \'..\' even if they are present in the directory."); #define OS_LISTDIR_METHODDEF \ - {"listdir", (PyCFunction)os_listdir, METH_VARARGS|METH_KEYWORDS, os_listdir__doc__}, + {"listdir", (PyCFunction)os_listdir, METH_FASTCALL, os_listdir__doc__}, static PyObject * os_listdir_impl(PyModuleDef *module, path_t *path); static PyObject * -os_listdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_listdir(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", NULL}; path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O&:listdir", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O&:listdir", _keywords, path_converter, &path)) goto exit; return_value = os_listdir_impl(module, &path); @@ -991,19 +991,19 @@ PyDoc_STRVAR(os__getvolumepathname__doc_ "A helper function for ismount on Win32."); #define OS__GETVOLUMEPATHNAME_METHODDEF \ - {"_getvolumepathname", (PyCFunction)os__getvolumepathname, METH_VARARGS|METH_KEYWORDS, os__getvolumepathname__doc__}, + {"_getvolumepathname", (PyCFunction)os__getvolumepathname, METH_FASTCALL, os__getvolumepathname__doc__}, static PyObject * os__getvolumepathname_impl(PyModuleDef *module, PyObject *path); static PyObject * -os__getvolumepathname(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os__getvolumepathname(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", NULL}; PyObject *path; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "U:_getvolumepathname", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "U:_getvolumepathname", _keywords, &path)) goto exit; return_value = os__getvolumepathname_impl(module, path); @@ -1028,13 +1028,13 @@ PyDoc_STRVAR(os_mkdir__doc__, "The mode argument is ignored on Windows."); #define OS_MKDIR_METHODDEF \ - {"mkdir", (PyCFunction)os_mkdir, METH_VARARGS|METH_KEYWORDS, os_mkdir__doc__}, + {"mkdir", (PyCFunction)os_mkdir, METH_FASTCALL, os_mkdir__doc__}, static PyObject * os_mkdir_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd); static PyObject * -os_mkdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_mkdir(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "mode", "dir_fd", NULL}; @@ -1042,7 +1042,7 @@ os_mkdir(PyModuleDef *module, PyObject * int mode = 511; int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i$O&:mkdir", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|i$O&:mkdir", _keywords, path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_mkdir_impl(module, &path, mode, dir_fd); @@ -1093,20 +1093,20 @@ PyDoc_STRVAR(os_getpriority__doc__, "Return program scheduling priority."); #define OS_GETPRIORITY_METHODDEF \ - {"getpriority", (PyCFunction)os_getpriority, METH_VARARGS|METH_KEYWORDS, os_getpriority__doc__}, + {"getpriority", (PyCFunction)os_getpriority, METH_FASTCALL, os_getpriority__doc__}, static PyObject * os_getpriority_impl(PyModuleDef *module, int which, int who); static PyObject * -os_getpriority(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_getpriority(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"which", "who", NULL}; int which; int who; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:getpriority", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "ii:getpriority", _keywords, &which, &who)) goto exit; return_value = os_getpriority_impl(module, which, who); @@ -1126,13 +1126,13 @@ PyDoc_STRVAR(os_setpriority__doc__, "Set program scheduling priority."); #define OS_SETPRIORITY_METHODDEF \ - {"setpriority", (PyCFunction)os_setpriority, METH_VARARGS|METH_KEYWORDS, os_setpriority__doc__}, + {"setpriority", (PyCFunction)os_setpriority, METH_FASTCALL, os_setpriority__doc__}, static PyObject * os_setpriority_impl(PyModuleDef *module, int which, int who, int priority); static PyObject * -os_setpriority(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_setpriority(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"which", "who", "priority", NULL}; @@ -1140,7 +1140,7 @@ os_setpriority(PyModuleDef *module, PyOb int who; int priority; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii:setpriority", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "iii:setpriority", _keywords, &which, &who, &priority)) goto exit; return_value = os_setpriority_impl(module, which, who, priority); @@ -1164,14 +1164,14 @@ PyDoc_STRVAR(os_rename__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_RENAME_METHODDEF \ - {"rename", (PyCFunction)os_rename, METH_VARARGS|METH_KEYWORDS, os_rename__doc__}, + {"rename", (PyCFunction)os_rename, METH_FASTCALL, os_rename__doc__}, static PyObject * os_rename_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd); static PyObject * -os_rename(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_rename(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; @@ -1180,7 +1180,7 @@ os_rename(PyModuleDef *module, PyObject int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$O&O&:rename", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&|$O&O&:rename", _keywords, path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) goto exit; return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); @@ -1207,14 +1207,14 @@ PyDoc_STRVAR(os_replace__doc__, " If they are unavailable, using them will raise a NotImplementedError.\""); #define OS_REPLACE_METHODDEF \ - {"replace", (PyCFunction)os_replace, METH_VARARGS|METH_KEYWORDS, os_replace__doc__}, + {"replace", (PyCFunction)os_replace, METH_FASTCALL, os_replace__doc__}, static PyObject * os_replace_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd); static PyObject * -os_replace(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_replace(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; @@ -1223,7 +1223,7 @@ os_replace(PyModuleDef *module, PyObject int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$O&O&:replace", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&|$O&O&:replace", _keywords, path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) goto exit; return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); @@ -1249,20 +1249,20 @@ PyDoc_STRVAR(os_rmdir__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_RMDIR_METHODDEF \ - {"rmdir", (PyCFunction)os_rmdir, METH_VARARGS|METH_KEYWORDS, os_rmdir__doc__}, + {"rmdir", (PyCFunction)os_rmdir, METH_FASTCALL, os_rmdir__doc__}, static PyObject * os_rmdir_impl(PyModuleDef *module, path_t *path, int dir_fd); static PyObject * -os_rmdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_rmdir(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "dir_fd", NULL}; path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:rmdir", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|$O&:rmdir", _keywords, path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_rmdir_impl(module, &path, dir_fd); @@ -1283,20 +1283,20 @@ PyDoc_STRVAR(os_system__doc__, "Execute the command in a subshell."); #define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)os_system, METH_VARARGS|METH_KEYWORDS, os_system__doc__}, + {"system", (PyCFunction)os_system, METH_FASTCALL, os_system__doc__}, static long os_system_impl(PyModuleDef *module, Py_UNICODE *command); static PyObject * -os_system(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_system(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"command", NULL}; Py_UNICODE *command; long _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "u:system", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "u:system", _keywords, &command)) goto exit; _return_value = os_system_impl(module, command); @@ -1319,20 +1319,20 @@ PyDoc_STRVAR(os_system__doc__, "Execute the command in a subshell."); #define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)os_system, METH_VARARGS|METH_KEYWORDS, os_system__doc__}, + {"system", (PyCFunction)os_system, METH_FASTCALL, os_system__doc__}, static long os_system_impl(PyModuleDef *module, PyObject *command); static PyObject * -os_system(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_system(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"command", NULL}; PyObject *command = NULL; long _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:system", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:system", _keywords, PyUnicode_FSConverter, &command)) goto exit; _return_value = os_system_impl(module, command); @@ -1387,20 +1387,20 @@ PyDoc_STRVAR(os_unlink__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_UNLINK_METHODDEF \ - {"unlink", (PyCFunction)os_unlink, METH_VARARGS|METH_KEYWORDS, os_unlink__doc__}, + {"unlink", (PyCFunction)os_unlink, METH_FASTCALL, os_unlink__doc__}, static PyObject * os_unlink_impl(PyModuleDef *module, path_t *path, int dir_fd); static PyObject * -os_unlink(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_unlink(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "dir_fd", NULL}; path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:unlink", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|$O&:unlink", _keywords, path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_unlink_impl(module, &path, dir_fd); @@ -1424,20 +1424,20 @@ PyDoc_STRVAR(os_remove__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_REMOVE_METHODDEF \ - {"remove", (PyCFunction)os_remove, METH_VARARGS|METH_KEYWORDS, os_remove__doc__}, + {"remove", (PyCFunction)os_remove, METH_FASTCALL, os_remove__doc__}, static PyObject * os_remove_impl(PyModuleDef *module, path_t *path, int dir_fd); static PyObject * -os_remove(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_remove(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "dir_fd", NULL}; path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:remove", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|$O&:remove", _keywords, path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_remove_impl(module, &path, dir_fd); @@ -1504,14 +1504,14 @@ PyDoc_STRVAR(os_utime__doc__, " If they are unavailable, using them will raise a NotImplementedError."); #define OS_UTIME_METHODDEF \ - {"utime", (PyCFunction)os_utime, METH_VARARGS|METH_KEYWORDS, os_utime__doc__}, + {"utime", (PyCFunction)os_utime, METH_FASTCALL, os_utime__doc__}, static PyObject * os_utime_impl(PyModuleDef *module, path_t *path, PyObject *times, PyObject *ns, int dir_fd, int follow_symlinks); static PyObject * -os_utime(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_utime(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; @@ -1521,7 +1521,7 @@ os_utime(PyModuleDef *module, PyObject * int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|O$OO&p:utime", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|O$OO&p:utime", _keywords, path_converter, &path, ×, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) goto exit; return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); @@ -1540,19 +1540,19 @@ PyDoc_STRVAR(os__exit__doc__, "Exit to the system with specified status, without normal exit processing."); #define OS__EXIT_METHODDEF \ - {"_exit", (PyCFunction)os__exit, METH_VARARGS|METH_KEYWORDS, os__exit__doc__}, + {"_exit", (PyCFunction)os__exit, METH_FASTCALL, os__exit__doc__}, static PyObject * os__exit_impl(PyModuleDef *module, int status); static PyObject * -os__exit(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os__exit(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:_exit", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:_exit", _keywords, &status)) goto exit; return_value = os__exit_impl(module, status); @@ -1575,21 +1575,23 @@ PyDoc_STRVAR(os_execv__doc__, " Tuple or list of strings."); #define OS_EXECV_METHODDEF \ - {"execv", (PyCFunction)os_execv, METH_VARARGS, os_execv__doc__}, + {"execv", (PyCFunction)os_execv, METH_FASTCALL, os_execv__doc__}, static PyObject * os_execv_impl(PyModuleDef *module, PyObject *path, PyObject *argv); static PyObject * -os_execv(PyModuleDef *module, PyObject *args) +os_execv(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *path = NULL; PyObject *argv; - if (!PyArg_ParseTuple(args, "O&O:execv", + if (!PyArg_ParseStack(stack, nargs, "O&O:execv", PyUnicode_FSConverter, &path, &argv)) goto exit; + if (!_PyArg_NoKeywords("execv()", kwargs)) + goto exit; return_value = os_execv_impl(module, path, argv); exit: @@ -1617,14 +1619,14 @@ PyDoc_STRVAR(os_execve__doc__, " Dictionary of strings mapping to strings."); #define OS_EXECVE_METHODDEF \ - {"execve", (PyCFunction)os_execve, METH_VARARGS|METH_KEYWORDS, os_execve__doc__}, + {"execve", (PyCFunction)os_execve, METH_FASTCALL, os_execve__doc__}, static PyObject * os_execve_impl(PyModuleDef *module, path_t *path, PyObject *argv, PyObject *env); static PyObject * -os_execve(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_execve(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "argv", "env", NULL}; @@ -1632,7 +1634,7 @@ os_execve(PyModuleDef *module, PyObject PyObject *argv; PyObject *env; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&OO:execve", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&OO:execve", _keywords, path_converter, &path, &argv, &env)) goto exit; return_value = os_execve_impl(module, &path, argv, env); @@ -1662,22 +1664,24 @@ PyDoc_STRVAR(os_spawnv__doc__, " Tuple or list of strings."); #define OS_SPAWNV_METHODDEF \ - {"spawnv", (PyCFunction)os_spawnv, METH_VARARGS, os_spawnv__doc__}, + {"spawnv", (PyCFunction)os_spawnv, METH_FASTCALL, os_spawnv__doc__}, static PyObject * os_spawnv_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv); static PyObject * -os_spawnv(PyModuleDef *module, PyObject *args) +os_spawnv(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int mode; PyObject *path = NULL; PyObject *argv; - if (!PyArg_ParseTuple(args, "iO&O:spawnv", + if (!PyArg_ParseStack(stack, nargs, "iO&O:spawnv", &mode, PyUnicode_FSConverter, &path, &argv)) goto exit; + if (!_PyArg_NoKeywords("spawnv()", kwargs)) + goto exit; return_value = os_spawnv_impl(module, mode, path, argv); exit: @@ -1707,14 +1711,14 @@ PyDoc_STRVAR(os_spawnve__doc__, " Dictionary of strings mapping to strings."); #define OS_SPAWNVE_METHODDEF \ - {"spawnve", (PyCFunction)os_spawnve, METH_VARARGS, os_spawnve__doc__}, + {"spawnve", (PyCFunction)os_spawnve, METH_FASTCALL, os_spawnve__doc__}, static PyObject * os_spawnve_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv, PyObject *env); static PyObject * -os_spawnve(PyModuleDef *module, PyObject *args) +os_spawnve(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int mode; @@ -1722,9 +1726,11 @@ os_spawnve(PyModuleDef *module, PyObject PyObject *argv; PyObject *env; - if (!PyArg_ParseTuple(args, "iO&OO:spawnve", + if (!PyArg_ParseStack(stack, nargs, "iO&OO:spawnve", &mode, PyUnicode_FSConverter, &path, &argv, &env)) goto exit; + if (!_PyArg_NoKeywords("spawnve()", kwargs)) + goto exit; return_value = os_spawnve_impl(module, mode, path, argv, env); exit: @@ -1793,19 +1799,19 @@ PyDoc_STRVAR(os_sched_get_priority_max__ "Get the maximum scheduling priority for policy."); #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ - {"sched_get_priority_max", (PyCFunction)os_sched_get_priority_max, METH_VARARGS|METH_KEYWORDS, os_sched_get_priority_max__doc__}, + {"sched_get_priority_max", (PyCFunction)os_sched_get_priority_max, METH_FASTCALL, os_sched_get_priority_max__doc__}, static PyObject * os_sched_get_priority_max_impl(PyModuleDef *module, int policy); static PyObject * -os_sched_get_priority_max(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_sched_get_priority_max(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"policy", NULL}; int policy; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:sched_get_priority_max", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:sched_get_priority_max", _keywords, &policy)) goto exit; return_value = os_sched_get_priority_max_impl(module, policy); @@ -1825,19 +1831,19 @@ PyDoc_STRVAR(os_sched_get_priority_min__ "Get the minimum scheduling priority for policy."); #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ - {"sched_get_priority_min", (PyCFunction)os_sched_get_priority_min, METH_VARARGS|METH_KEYWORDS, os_sched_get_priority_min__doc__}, + {"sched_get_priority_min", (PyCFunction)os_sched_get_priority_min, METH_FASTCALL, os_sched_get_priority_min__doc__}, static PyObject * os_sched_get_priority_min_impl(PyModuleDef *module, int policy); static PyObject * -os_sched_get_priority_min(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_sched_get_priority_min(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"policy", NULL}; int policy; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:sched_get_priority_min", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:sched_get_priority_min", _keywords, &policy)) goto exit; return_value = os_sched_get_priority_min_impl(module, policy); @@ -1924,23 +1930,25 @@ PyDoc_STRVAR(os_sched_setscheduler__doc_ "param is an instance of sched_param."); #define OS_SCHED_SETSCHEDULER_METHODDEF \ - {"sched_setscheduler", (PyCFunction)os_sched_setscheduler, METH_VARARGS, os_sched_setscheduler__doc__}, + {"sched_setscheduler", (PyCFunction)os_sched_setscheduler, METH_FASTCALL, os_sched_setscheduler__doc__}, static PyObject * os_sched_setscheduler_impl(PyModuleDef *module, pid_t pid, int policy, struct sched_param *param); static PyObject * -os_sched_setscheduler(PyModuleDef *module, PyObject *args) +os_sched_setscheduler(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pid; int policy; struct sched_param param; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "iO&:sched_setscheduler", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "iO&:sched_setscheduler", &pid, &policy, convert_sched_param, ¶m)) goto exit; + if (!_PyArg_NoKeywords("sched_setscheduler()", kwargs)) + goto exit; return_value = os_sched_setscheduler_impl(module, pid, policy, ¶m); exit: @@ -1994,22 +2002,24 @@ PyDoc_STRVAR(os_sched_setparam__doc__, "param should be an instance of sched_param."); #define OS_SCHED_SETPARAM_METHODDEF \ - {"sched_setparam", (PyCFunction)os_sched_setparam, METH_VARARGS, os_sched_setparam__doc__}, + {"sched_setparam", (PyCFunction)os_sched_setparam, METH_FASTCALL, os_sched_setparam__doc__}, static PyObject * os_sched_setparam_impl(PyModuleDef *module, pid_t pid, struct sched_param *param); static PyObject * -os_sched_setparam(PyModuleDef *module, PyObject *args) +os_sched_setparam(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pid; struct sched_param param; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "O&:sched_setparam", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "O&:sched_setparam", &pid, convert_sched_param, ¶m)) goto exit; + if (!_PyArg_NoKeywords("sched_setparam()", kwargs)) + goto exit; return_value = os_sched_setparam_impl(module, pid, ¶m); exit: @@ -2087,21 +2097,23 @@ PyDoc_STRVAR(os_sched_setaffinity__doc__ "mask should be an iterable of integers identifying CPUs."); #define OS_SCHED_SETAFFINITY_METHODDEF \ - {"sched_setaffinity", (PyCFunction)os_sched_setaffinity, METH_VARARGS, os_sched_setaffinity__doc__}, + {"sched_setaffinity", (PyCFunction)os_sched_setaffinity, METH_FASTCALL, os_sched_setaffinity__doc__}, static PyObject * os_sched_setaffinity_impl(PyModuleDef *module, pid_t pid, PyObject *mask); static PyObject * -os_sched_setaffinity(PyModuleDef *module, PyObject *args) +os_sched_setaffinity(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pid; PyObject *mask; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "O:sched_setaffinity", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "O:sched_setaffinity", &pid, &mask)) goto exit; + if (!_PyArg_NoKeywords("sched_setaffinity()", kwargs)) + goto exit; return_value = os_sched_setaffinity_impl(module, pid, mask); exit: @@ -2309,19 +2321,19 @@ PyDoc_STRVAR(os_getpgid__doc__, "Call the system call getpgid(), and return the result."); #define OS_GETPGID_METHODDEF \ - {"getpgid", (PyCFunction)os_getpgid, METH_VARARGS|METH_KEYWORDS, os_getpgid__doc__}, + {"getpgid", (PyCFunction)os_getpgid, METH_FASTCALL, os_getpgid__doc__}, static PyObject * os_getpgid_impl(PyModuleDef *module, pid_t pid); static PyObject * -os_getpgid(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_getpgid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"pid", NULL}; pid_t pid; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" _Py_PARSE_PID ":getpgid", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "" _Py_PARSE_PID ":getpgid", _keywords, &pid)) goto exit; return_value = os_getpgid_impl(module, pid); @@ -2454,21 +2466,23 @@ PyDoc_STRVAR(os_kill__doc__, "Kill a process with a signal."); #define OS_KILL_METHODDEF \ - {"kill", (PyCFunction)os_kill, METH_VARARGS, os_kill__doc__}, + {"kill", (PyCFunction)os_kill, METH_FASTCALL, os_kill__doc__}, static PyObject * os_kill_impl(PyModuleDef *module, pid_t pid, Py_ssize_t signal); static PyObject * -os_kill(PyModuleDef *module, PyObject *args) +os_kill(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pid; Py_ssize_t signal; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "n:kill", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "n:kill", &pid, &signal)) goto exit; + if (!_PyArg_NoKeywords("kill()", kwargs)) + goto exit; return_value = os_kill_impl(module, pid, signal); exit: @@ -2486,21 +2500,23 @@ PyDoc_STRVAR(os_killpg__doc__, "Kill a process group with a signal."); #define OS_KILLPG_METHODDEF \ - {"killpg", (PyCFunction)os_killpg, METH_VARARGS, os_killpg__doc__}, + {"killpg", (PyCFunction)os_killpg, METH_FASTCALL, os_killpg__doc__}, static PyObject * os_killpg_impl(PyModuleDef *module, pid_t pgid, int signal); static PyObject * -os_killpg(PyModuleDef *module, PyObject *args) +os_killpg(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pgid; int signal; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:killpg", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "i:killpg", &pgid, &signal)) goto exit; + if (!_PyArg_NoKeywords("killpg()", kwargs)) + goto exit; return_value = os_killpg_impl(module, pgid, signal); exit: @@ -2638,21 +2654,23 @@ PyDoc_STRVAR(os_setreuid__doc__, "Set the current process\'s real and effective user ids."); #define OS_SETREUID_METHODDEF \ - {"setreuid", (PyCFunction)os_setreuid, METH_VARARGS, os_setreuid__doc__}, + {"setreuid", (PyCFunction)os_setreuid, METH_FASTCALL, os_setreuid__doc__}, static PyObject * os_setreuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid); static PyObject * -os_setreuid(PyModuleDef *module, PyObject *args) +os_setreuid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; uid_t ruid; uid_t euid; - if (!PyArg_ParseTuple(args, "O&O&:setreuid", + if (!PyArg_ParseStack(stack, nargs, "O&O&:setreuid", _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) goto exit; + if (!_PyArg_NoKeywords("setreuid()", kwargs)) + goto exit; return_value = os_setreuid_impl(module, ruid, euid); exit: @@ -2670,21 +2688,23 @@ PyDoc_STRVAR(os_setregid__doc__, "Set the current process\'s real and effective group ids."); #define OS_SETREGID_METHODDEF \ - {"setregid", (PyCFunction)os_setregid, METH_VARARGS, os_setregid__doc__}, + {"setregid", (PyCFunction)os_setregid, METH_FASTCALL, os_setregid__doc__}, static PyObject * os_setregid_impl(PyModuleDef *module, gid_t rgid, gid_t egid); static PyObject * -os_setregid(PyModuleDef *module, PyObject *args) +os_setregid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; gid_t rgid; gid_t egid; - if (!PyArg_ParseTuple(args, "O&O&:setregid", + if (!PyArg_ParseStack(stack, nargs, "O&O&:setregid", _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) goto exit; + if (!_PyArg_NoKeywords("setregid()", kwargs)) + goto exit; return_value = os_setregid_impl(module, rgid, egid); exit: @@ -2748,19 +2768,19 @@ PyDoc_STRVAR(os_wait3__doc__, " (pid, status, rusage)"); #define OS_WAIT3_METHODDEF \ - {"wait3", (PyCFunction)os_wait3, METH_VARARGS|METH_KEYWORDS, os_wait3__doc__}, + {"wait3", (PyCFunction)os_wait3, METH_FASTCALL, os_wait3__doc__}, static PyObject * os_wait3_impl(PyModuleDef *module, int options); static PyObject * -os_wait3(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_wait3(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"options", NULL}; int options; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:wait3", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:wait3", _keywords, &options)) goto exit; return_value = os_wait3_impl(module, options); @@ -2783,20 +2803,20 @@ PyDoc_STRVAR(os_wait4__doc__, " (pid, status, rusage)"); #define OS_WAIT4_METHODDEF \ - {"wait4", (PyCFunction)os_wait4, METH_VARARGS|METH_KEYWORDS, os_wait4__doc__}, + {"wait4", (PyCFunction)os_wait4, METH_FASTCALL, os_wait4__doc__}, static PyObject * os_wait4_impl(PyModuleDef *module, pid_t pid, int options); static PyObject * -os_wait4(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_wait4(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"pid", "options", NULL}; pid_t pid; int options; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" _Py_PARSE_PID "i:wait4", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "" _Py_PARSE_PID "i:wait4", _keywords, &pid, &options)) goto exit; return_value = os_wait4_impl(module, pid, options); @@ -2827,22 +2847,24 @@ PyDoc_STRVAR(os_waitid__doc__, "no children in a waitable state."); #define OS_WAITID_METHODDEF \ - {"waitid", (PyCFunction)os_waitid, METH_VARARGS, os_waitid__doc__}, + {"waitid", (PyCFunction)os_waitid, METH_FASTCALL, os_waitid__doc__}, static PyObject * os_waitid_impl(PyModuleDef *module, idtype_t idtype, id_t id, int options); static PyObject * -os_waitid(PyModuleDef *module, PyObject *args) +os_waitid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; idtype_t idtype; id_t id; int options; - if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID "i:waitid", + if (!PyArg_ParseStack(stack, nargs, "i" _Py_PARSE_PID "i:waitid", &idtype, &id, &options)) goto exit; + if (!_PyArg_NoKeywords("waitid()", kwargs)) + goto exit; return_value = os_waitid_impl(module, idtype, id, options); exit: @@ -2865,21 +2887,23 @@ PyDoc_STRVAR(os_waitpid__doc__, "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, + {"waitpid", (PyCFunction)os_waitpid, METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyModuleDef *module, pid_t pid, int options); static PyObject * -os_waitpid(PyModuleDef *module, PyObject *args) +os_waitpid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pid; int options; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:waitpid", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "i:waitpid", &pid, &options)) goto exit; + if (!_PyArg_NoKeywords("waitpid()", kwargs)) + goto exit; return_value = os_waitpid_impl(module, pid, options); exit: @@ -2902,21 +2926,23 @@ PyDoc_STRVAR(os_waitpid__doc__, "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, + {"waitpid", (PyCFunction)os_waitpid, METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyModuleDef *module, Py_intptr_t pid, int options); static PyObject * -os_waitpid(PyModuleDef *module, PyObject *args) +os_waitpid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_intptr_t pid; int options; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "i:waitpid", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_INTPTR "i:waitpid", &pid, &options)) goto exit; + if (!_PyArg_NoKeywords("waitpid()", kwargs)) + goto exit; return_value = os_waitpid_impl(module, pid, options); exit: @@ -2969,14 +2995,14 @@ PyDoc_STRVAR(os_symlink__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_SYMLINK_METHODDEF \ - {"symlink", (PyCFunction)os_symlink, METH_VARARGS|METH_KEYWORDS, os_symlink__doc__}, + {"symlink", (PyCFunction)os_symlink, METH_FASTCALL, os_symlink__doc__}, static PyObject * os_symlink_impl(PyModuleDef *module, path_t *src, path_t *dst, int target_is_directory, int dir_fd); static PyObject * -os_symlink(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_symlink(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; @@ -2985,7 +3011,7 @@ os_symlink(PyModuleDef *module, PyObject int target_is_directory = 0; int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|p$O&:symlink", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&|p$O&:symlink", _keywords, path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); @@ -3088,21 +3114,23 @@ PyDoc_STRVAR(os_setpgid__doc__, "Call the system call setpgid(pid, pgrp)."); #define OS_SETPGID_METHODDEF \ - {"setpgid", (PyCFunction)os_setpgid, METH_VARARGS, os_setpgid__doc__}, + {"setpgid", (PyCFunction)os_setpgid, METH_FASTCALL, os_setpgid__doc__}, static PyObject * os_setpgid_impl(PyModuleDef *module, pid_t pid, pid_t pgrp); static PyObject * -os_setpgid(PyModuleDef *module, PyObject *args) +os_setpgid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; pid_t pid; pid_t pgrp; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid", &pid, &pgrp)) goto exit; + if (!_PyArg_NoKeywords("setpgid()", kwargs)) + goto exit; return_value = os_setpgid_impl(module, pid, pgrp); exit: @@ -3150,21 +3178,23 @@ PyDoc_STRVAR(os_tcsetpgrp__doc__, "Set the process group associated with the terminal specified by fd."); #define OS_TCSETPGRP_METHODDEF \ - {"tcsetpgrp", (PyCFunction)os_tcsetpgrp, METH_VARARGS, os_tcsetpgrp__doc__}, + {"tcsetpgrp", (PyCFunction)os_tcsetpgrp, METH_FASTCALL, os_tcsetpgrp__doc__}, static PyObject * os_tcsetpgrp_impl(PyModuleDef *module, int fd, pid_t pgid); static PyObject * -os_tcsetpgrp(PyModuleDef *module, PyObject *args) +os_tcsetpgrp(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; pid_t pgid; - if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID ":tcsetpgrp", + if (!PyArg_ParseStack(stack, nargs, "i" _Py_PARSE_PID ":tcsetpgrp", &fd, &pgid)) goto exit; + if (!_PyArg_NoKeywords("tcsetpgrp()", kwargs)) + goto exit; return_value = os_tcsetpgrp_impl(module, fd, pgid); exit: @@ -3185,14 +3215,14 @@ PyDoc_STRVAR(os_open__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_OPEN_METHODDEF \ - {"open", (PyCFunction)os_open, METH_VARARGS|METH_KEYWORDS, os_open__doc__}, + {"open", (PyCFunction)os_open, METH_FASTCALL, os_open__doc__}, static int os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode, int dir_fd); static PyObject * -os_open(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_open(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; @@ -3202,7 +3232,7 @@ os_open(PyModuleDef *module, PyObject *a int dir_fd = DEFAULT_DIR_FD; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i|i$O&:open", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&i|i$O&:open", _keywords, path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; _return_value = os_open_impl(module, &path, flags, mode, dir_fd); @@ -3224,19 +3254,19 @@ PyDoc_STRVAR(os_close__doc__, "Close a file descriptor."); #define OS_CLOSE_METHODDEF \ - {"close", (PyCFunction)os_close, METH_VARARGS|METH_KEYWORDS, os_close__doc__}, + {"close", (PyCFunction)os_close, METH_FASTCALL, os_close__doc__}, static PyObject * os_close_impl(PyModuleDef *module, int fd); static PyObject * -os_close(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_close(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", NULL}; int fd; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:close", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:close", _keywords, &fd)) goto exit; return_value = os_close_impl(module, fd); @@ -3252,21 +3282,23 @@ PyDoc_STRVAR(os_closerange__doc__, "Closes all file descriptors in [fd_low, fd_high), ignoring errors."); #define OS_CLOSERANGE_METHODDEF \ - {"closerange", (PyCFunction)os_closerange, METH_VARARGS, os_closerange__doc__}, + {"closerange", (PyCFunction)os_closerange, METH_FASTCALL, os_closerange__doc__}, static PyObject * os_closerange_impl(PyModuleDef *module, int fd_low, int fd_high); static PyObject * -os_closerange(PyModuleDef *module, PyObject *args) +os_closerange(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd_low; int fd_high; - if (!PyArg_ParseTuple(args, "ii:closerange", + if (!PyArg_ParseStack(stack, nargs, "ii:closerange", &fd_low, &fd_high)) goto exit; + if (!_PyArg_NoKeywords("closerange()", kwargs)) + goto exit; return_value = os_closerange_impl(module, fd_low, fd_high); exit: @@ -3310,13 +3342,13 @@ PyDoc_STRVAR(os_dup2__doc__, "Duplicate file descriptor."); #define OS_DUP2_METHODDEF \ - {"dup2", (PyCFunction)os_dup2, METH_VARARGS|METH_KEYWORDS, os_dup2__doc__}, + {"dup2", (PyCFunction)os_dup2, METH_FASTCALL, os_dup2__doc__}, static PyObject * os_dup2_impl(PyModuleDef *module, int fd, int fd2, int inheritable); static PyObject * -os_dup2(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_dup2(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", "fd2", "inheritable", NULL}; @@ -3324,7 +3356,7 @@ os_dup2(PyModuleDef *module, PyObject *a int fd2; int inheritable = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|p:dup2", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "ii|p:dup2", _keywords, &fd, &fd2, &inheritable)) goto exit; return_value = os_dup2_impl(module, fd, fd2, inheritable); @@ -3349,22 +3381,24 @@ PyDoc_STRVAR(os_lockf__doc__, " The number of bytes to lock, starting at the current position."); #define OS_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)os_lockf, METH_VARARGS, os_lockf__doc__}, + {"lockf", (PyCFunction)os_lockf, METH_FASTCALL, os_lockf__doc__}, static PyObject * os_lockf_impl(PyModuleDef *module, int fd, int command, Py_off_t length); static PyObject * -os_lockf(PyModuleDef *module, PyObject *args) +os_lockf(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int command; Py_off_t length; - if (!PyArg_ParseTuple(args, "iiO&:lockf", + if (!PyArg_ParseStack(stack, nargs, "iiO&:lockf", &fd, &command, Py_off_t_converter, &length)) goto exit; + if (!_PyArg_NoKeywords("lockf()", kwargs)) + goto exit; return_value = os_lockf_impl(module, fd, command, length); exit: @@ -3383,13 +3417,13 @@ PyDoc_STRVAR(os_lseek__doc__, "relative to the beginning of the file."); #define OS_LSEEK_METHODDEF \ - {"lseek", (PyCFunction)os_lseek, METH_VARARGS, os_lseek__doc__}, + {"lseek", (PyCFunction)os_lseek, METH_FASTCALL, os_lseek__doc__}, static Py_off_t os_lseek_impl(PyModuleDef *module, int fd, Py_off_t position, int how); static PyObject * -os_lseek(PyModuleDef *module, PyObject *args) +os_lseek(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; @@ -3397,9 +3431,11 @@ os_lseek(PyModuleDef *module, PyObject * int how; Py_off_t _return_value; - if (!PyArg_ParseTuple(args, "iO&i:lseek", + if (!PyArg_ParseStack(stack, nargs, "iO&i:lseek", &fd, Py_off_t_converter, &position, &how)) goto exit; + if (!_PyArg_NoKeywords("lseek()", kwargs)) + goto exit; _return_value = os_lseek_impl(module, fd, position, how); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -3416,21 +3452,23 @@ PyDoc_STRVAR(os_read__doc__, "Read from a file descriptor. Returns a bytes object."); #define OS_READ_METHODDEF \ - {"read", (PyCFunction)os_read, METH_VARARGS, os_read__doc__}, + {"read", (PyCFunction)os_read, METH_FASTCALL, os_read__doc__}, static PyObject * os_read_impl(PyModuleDef *module, int fd, Py_ssize_t length); static PyObject * -os_read(PyModuleDef *module, PyObject *args) +os_read(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; Py_ssize_t length; - if (!PyArg_ParseTuple(args, "in:read", + if (!PyArg_ParseStack(stack, nargs, "in:read", &fd, &length)) goto exit; + if (!_PyArg_NoKeywords("read()", kwargs)) + goto exit; return_value = os_read_impl(module, fd, length); exit: @@ -3454,22 +3492,24 @@ PyDoc_STRVAR(os_readv__doc__, "which may be less than the total capacity of all the buffers."); #define OS_READV_METHODDEF \ - {"readv", (PyCFunction)os_readv, METH_VARARGS, os_readv__doc__}, + {"readv", (PyCFunction)os_readv, METH_FASTCALL, os_readv__doc__}, static Py_ssize_t os_readv_impl(PyModuleDef *module, int fd, PyObject *buffers); static PyObject * -os_readv(PyModuleDef *module, PyObject *args) +os_readv(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; PyObject *buffers; Py_ssize_t _return_value; - if (!PyArg_ParseTuple(args, "iO:readv", + if (!PyArg_ParseStack(stack, nargs, "iO:readv", &fd, &buffers)) goto exit; + if (!_PyArg_NoKeywords("readv()", kwargs)) + goto exit; _return_value = os_readv_impl(module, fd, buffers); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -3493,22 +3533,24 @@ PyDoc_STRVAR(os_pread__doc__, "the beginning of the file. The file offset remains unchanged."); #define OS_PREAD_METHODDEF \ - {"pread", (PyCFunction)os_pread, METH_VARARGS, os_pread__doc__}, + {"pread", (PyCFunction)os_pread, METH_FASTCALL, os_pread__doc__}, static PyObject * os_pread_impl(PyModuleDef *module, int fd, int length, Py_off_t offset); static PyObject * -os_pread(PyModuleDef *module, PyObject *args) +os_pread(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int length; Py_off_t offset; - if (!PyArg_ParseTuple(args, "iiO&:pread", + if (!PyArg_ParseStack(stack, nargs, "iiO&:pread", &fd, &length, Py_off_t_converter, &offset)) goto exit; + if (!_PyArg_NoKeywords("pread()", kwargs)) + goto exit; return_value = os_pread_impl(module, fd, length, offset); exit: @@ -3524,22 +3566,24 @@ PyDoc_STRVAR(os_write__doc__, "Write a bytes object to a file descriptor."); #define OS_WRITE_METHODDEF \ - {"write", (PyCFunction)os_write, METH_VARARGS, os_write__doc__}, + {"write", (PyCFunction)os_write, METH_FASTCALL, os_write__doc__}, static Py_ssize_t os_write_impl(PyModuleDef *module, int fd, Py_buffer *data); static PyObject * -os_write(PyModuleDef *module, PyObject *args) +os_write(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; Py_buffer data = {NULL, NULL}; Py_ssize_t _return_value; - if (!PyArg_ParseTuple(args, "iy*:write", + if (!PyArg_ParseStack(stack, nargs, "iy*:write", &fd, &data)) goto exit; + if (!_PyArg_NoKeywords("write()", kwargs)) + goto exit; _return_value = os_write_impl(module, fd, &data); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -3563,19 +3607,19 @@ PyDoc_STRVAR(os_fstat__doc__, "Equivalent to os.stat(fd)."); #define OS_FSTAT_METHODDEF \ - {"fstat", (PyCFunction)os_fstat, METH_VARARGS|METH_KEYWORDS, os_fstat__doc__}, + {"fstat", (PyCFunction)os_fstat, METH_FASTCALL, os_fstat__doc__}, static PyObject * os_fstat_impl(PyModuleDef *module, int fd); static PyObject * -os_fstat(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_fstat(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", NULL}; int fd; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:fstat", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:fstat", _keywords, &fd)) goto exit; return_value = os_fstat_impl(module, fd); @@ -3690,22 +3734,24 @@ PyDoc_STRVAR(os_writev__doc__, "buffers must be a sequence of bytes-like objects."); #define OS_WRITEV_METHODDEF \ - {"writev", (PyCFunction)os_writev, METH_VARARGS, os_writev__doc__}, + {"writev", (PyCFunction)os_writev, METH_FASTCALL, os_writev__doc__}, static Py_ssize_t os_writev_impl(PyModuleDef *module, int fd, PyObject *buffers); static PyObject * -os_writev(PyModuleDef *module, PyObject *args) +os_writev(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; PyObject *buffers; Py_ssize_t _return_value; - if (!PyArg_ParseTuple(args, "iO:writev", + if (!PyArg_ParseStack(stack, nargs, "iO:writev", &fd, &buffers)) goto exit; + if (!_PyArg_NoKeywords("writev()", kwargs)) + goto exit; _return_value = os_writev_impl(module, fd, buffers); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -3730,14 +3776,14 @@ PyDoc_STRVAR(os_pwrite__doc__, "current file offset."); #define OS_PWRITE_METHODDEF \ - {"pwrite", (PyCFunction)os_pwrite, METH_VARARGS, os_pwrite__doc__}, + {"pwrite", (PyCFunction)os_pwrite, METH_FASTCALL, os_pwrite__doc__}, static Py_ssize_t os_pwrite_impl(PyModuleDef *module, int fd, Py_buffer *buffer, Py_off_t offset); static PyObject * -os_pwrite(PyModuleDef *module, PyObject *args) +os_pwrite(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; @@ -3745,9 +3791,11 @@ os_pwrite(PyModuleDef *module, PyObject Py_off_t offset; Py_ssize_t _return_value; - if (!PyArg_ParseTuple(args, "iy*O&:pwrite", + if (!PyArg_ParseStack(stack, nargs, "iy*O&:pwrite", &fd, &buffer, Py_off_t_converter, &offset)) goto exit; + if (!_PyArg_NoKeywords("pwrite()", kwargs)) + goto exit; _return_value = os_pwrite_impl(module, fd, &buffer, offset); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -3777,13 +3825,13 @@ PyDoc_STRVAR(os_mkfifo__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_MKFIFO_METHODDEF \ - {"mkfifo", (PyCFunction)os_mkfifo, METH_VARARGS|METH_KEYWORDS, os_mkfifo__doc__}, + {"mkfifo", (PyCFunction)os_mkfifo, METH_FASTCALL, os_mkfifo__doc__}, static PyObject * os_mkfifo_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd); static PyObject * -os_mkfifo(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_mkfifo(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "mode", "dir_fd", NULL}; @@ -3791,7 +3839,7 @@ os_mkfifo(PyModuleDef *module, PyObject int mode = 438; int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i$O&:mkfifo", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|i$O&:mkfifo", _keywords, path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_mkfifo_impl(module, &path, mode, dir_fd); @@ -3826,14 +3874,14 @@ PyDoc_STRVAR(os_mknod__doc__, " If it is unavailable, using it will raise a NotImplementedError."); #define OS_MKNOD_METHODDEF \ - {"mknod", (PyCFunction)os_mknod, METH_VARARGS|METH_KEYWORDS, os_mknod__doc__}, + {"mknod", (PyCFunction)os_mknod, METH_FASTCALL, os_mknod__doc__}, static PyObject * os_mknod_impl(PyModuleDef *module, path_t *path, int mode, dev_t device, int dir_fd); static PyObject * -os_mknod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_mknod(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "mode", "device", "dir_fd", NULL}; @@ -3842,7 +3890,7 @@ os_mknod(PyModuleDef *module, PyObject * dev_t device = 0; int dir_fd = DEFAULT_DIR_FD; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|iO&$O&:mknod", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&|iO&$O&:mknod", _keywords, path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd)) goto exit; return_value = os_mknod_impl(module, &path, mode, device, dir_fd); @@ -3933,22 +3981,24 @@ PyDoc_STRVAR(os_makedev__doc__, "Composes a raw device number from the major and minor device numbers."); #define OS_MAKEDEV_METHODDEF \ - {"makedev", (PyCFunction)os_makedev, METH_VARARGS, os_makedev__doc__}, + {"makedev", (PyCFunction)os_makedev, METH_FASTCALL, os_makedev__doc__}, static dev_t os_makedev_impl(PyModuleDef *module, int major, int minor); static PyObject * -os_makedev(PyModuleDef *module, PyObject *args) +os_makedev(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int major; int minor; dev_t _return_value; - if (!PyArg_ParseTuple(args, "ii:makedev", + if (!PyArg_ParseStack(stack, nargs, "ii:makedev", &major, &minor)) goto exit; + if (!_PyArg_NoKeywords("makedev()", kwargs)) + goto exit; _return_value = os_makedev_impl(module, major, minor); if ((_return_value == (dev_t)-1) && PyErr_Occurred()) goto exit; @@ -3969,21 +4019,23 @@ PyDoc_STRVAR(os_ftruncate__doc__, "Truncate a file, specified by file descriptor, to a specific length."); #define OS_FTRUNCATE_METHODDEF \ - {"ftruncate", (PyCFunction)os_ftruncate, METH_VARARGS, os_ftruncate__doc__}, + {"ftruncate", (PyCFunction)os_ftruncate, METH_FASTCALL, os_ftruncate__doc__}, static PyObject * os_ftruncate_impl(PyModuleDef *module, int fd, Py_off_t length); static PyObject * -os_ftruncate(PyModuleDef *module, PyObject *args) +os_ftruncate(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; Py_off_t length; - if (!PyArg_ParseTuple(args, "iO&:ftruncate", + if (!PyArg_ParseStack(stack, nargs, "iO&:ftruncate", &fd, Py_off_t_converter, &length)) goto exit; + if (!_PyArg_NoKeywords("ftruncate()", kwargs)) + goto exit; return_value = os_ftruncate_impl(module, fd, length); exit: @@ -4004,20 +4056,20 @@ PyDoc_STRVAR(os_truncate__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)os_truncate, METH_VARARGS|METH_KEYWORDS, os_truncate__doc__}, + {"truncate", (PyCFunction)os_truncate, METH_FASTCALL, os_truncate__doc__}, static PyObject * os_truncate_impl(PyModuleDef *module, path_t *path, Py_off_t length); static PyObject * -os_truncate(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_truncate(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "length", NULL}; path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE); Py_off_t length; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&:truncate", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&:truncate", _keywords, path_converter, &path, Py_off_t_converter, &length)) goto exit; return_value = os_truncate_impl(module, &path, length); @@ -4043,23 +4095,25 @@ PyDoc_STRVAR(os_posix_fallocate__doc__, "starting at offset bytes from the beginning and continuing for length bytes."); #define OS_POSIX_FALLOCATE_METHODDEF \ - {"posix_fallocate", (PyCFunction)os_posix_fallocate, METH_VARARGS, os_posix_fallocate__doc__}, + {"posix_fallocate", (PyCFunction)os_posix_fallocate, METH_FASTCALL, os_posix_fallocate__doc__}, static PyObject * os_posix_fallocate_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length); static PyObject * -os_posix_fallocate(PyModuleDef *module, PyObject *args) +os_posix_fallocate(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; Py_off_t offset; Py_off_t length; - if (!PyArg_ParseTuple(args, "iO&O&:posix_fallocate", + if (!PyArg_ParseStack(stack, nargs, "iO&O&:posix_fallocate", &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) goto exit; + if (!_PyArg_NoKeywords("posix_fallocate()", kwargs)) + goto exit; return_value = os_posix_fallocate_impl(module, fd, offset, length); exit: @@ -4085,14 +4139,14 @@ PyDoc_STRVAR(os_posix_fadvise__doc__, "POSIX_FADV_DONTNEED."); #define OS_POSIX_FADVISE_METHODDEF \ - {"posix_fadvise", (PyCFunction)os_posix_fadvise, METH_VARARGS, os_posix_fadvise__doc__}, + {"posix_fadvise", (PyCFunction)os_posix_fadvise, METH_FASTCALL, os_posix_fadvise__doc__}, static PyObject * os_posix_fadvise_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length, int advice); static PyObject * -os_posix_fadvise(PyModuleDef *module, PyObject *args) +os_posix_fadvise(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; @@ -4100,9 +4154,11 @@ os_posix_fadvise(PyModuleDef *module, Py Py_off_t length; int advice; - if (!PyArg_ParseTuple(args, "iO&O&i:posix_fadvise", + if (!PyArg_ParseStack(stack, nargs, "iO&O&i:posix_fadvise", &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) goto exit; + if (!_PyArg_NoKeywords("posix_fadvise()", kwargs)) + goto exit; return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); exit: @@ -4120,21 +4176,23 @@ PyDoc_STRVAR(os_putenv__doc__, "Change or add an environment variable."); #define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__}, + {"putenv", (PyCFunction)os_putenv, METH_FASTCALL, os_putenv__doc__}, static PyObject * os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value); static PyObject * -os_putenv(PyModuleDef *module, PyObject *args) +os_putenv(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *name; PyObject *value; - if (!PyArg_ParseTuple(args, "UU:putenv", + if (!PyArg_ParseStack(stack, nargs, "UU:putenv", &name, &value)) goto exit; + if (!_PyArg_NoKeywords("putenv()", kwargs)) + goto exit; return_value = os_putenv_impl(module, name, value); exit: @@ -4152,21 +4210,23 @@ PyDoc_STRVAR(os_putenv__doc__, "Change or add an environment variable."); #define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__}, + {"putenv", (PyCFunction)os_putenv, METH_FASTCALL, os_putenv__doc__}, static PyObject * os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value); static PyObject * -os_putenv(PyModuleDef *module, PyObject *args) +os_putenv(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *name = NULL; PyObject *value = NULL; - if (!PyArg_ParseTuple(args, "O&O&:putenv", + if (!PyArg_ParseStack(stack, nargs, "O&O&:putenv", PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) goto exit; + if (!_PyArg_NoKeywords("putenv()", kwargs)) + goto exit; return_value = os_putenv_impl(module, name, value); exit: @@ -4285,20 +4345,20 @@ PyDoc_STRVAR(os_WIFCONTINUED__doc__, "job control stop."); #define OS_WIFCONTINUED_METHODDEF \ - {"WIFCONTINUED", (PyCFunction)os_WIFCONTINUED, METH_VARARGS|METH_KEYWORDS, os_WIFCONTINUED__doc__}, + {"WIFCONTINUED", (PyCFunction)os_WIFCONTINUED, METH_FASTCALL, os_WIFCONTINUED__doc__}, static int os_WIFCONTINUED_impl(PyModuleDef *module, int status); static PyObject * -os_WIFCONTINUED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WIFCONTINUED(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFCONTINUED", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WIFCONTINUED", _keywords, &status)) goto exit; _return_value = os_WIFCONTINUED_impl(module, status); @@ -4321,20 +4381,20 @@ PyDoc_STRVAR(os_WIFSTOPPED__doc__, "Return True if the process returning status was stopped."); #define OS_WIFSTOPPED_METHODDEF \ - {"WIFSTOPPED", (PyCFunction)os_WIFSTOPPED, METH_VARARGS|METH_KEYWORDS, os_WIFSTOPPED__doc__}, + {"WIFSTOPPED", (PyCFunction)os_WIFSTOPPED, METH_FASTCALL, os_WIFSTOPPED__doc__}, static int os_WIFSTOPPED_impl(PyModuleDef *module, int status); static PyObject * -os_WIFSTOPPED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WIFSTOPPED(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFSTOPPED", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WIFSTOPPED", _keywords, &status)) goto exit; _return_value = os_WIFSTOPPED_impl(module, status); @@ -4357,20 +4417,20 @@ PyDoc_STRVAR(os_WIFSIGNALED__doc__, "Return True if the process returning status was terminated by a signal."); #define OS_WIFSIGNALED_METHODDEF \ - {"WIFSIGNALED", (PyCFunction)os_WIFSIGNALED, METH_VARARGS|METH_KEYWORDS, os_WIFSIGNALED__doc__}, + {"WIFSIGNALED", (PyCFunction)os_WIFSIGNALED, METH_FASTCALL, os_WIFSIGNALED__doc__}, static int os_WIFSIGNALED_impl(PyModuleDef *module, int status); static PyObject * -os_WIFSIGNALED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WIFSIGNALED(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFSIGNALED", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WIFSIGNALED", _keywords, &status)) goto exit; _return_value = os_WIFSIGNALED_impl(module, status); @@ -4393,20 +4453,20 @@ PyDoc_STRVAR(os_WIFEXITED__doc__, "Return True if the process returning status exited via the exit() system call."); #define OS_WIFEXITED_METHODDEF \ - {"WIFEXITED", (PyCFunction)os_WIFEXITED, METH_VARARGS|METH_KEYWORDS, os_WIFEXITED__doc__}, + {"WIFEXITED", (PyCFunction)os_WIFEXITED, METH_FASTCALL, os_WIFEXITED__doc__}, static int os_WIFEXITED_impl(PyModuleDef *module, int status); static PyObject * -os_WIFEXITED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WIFEXITED(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFEXITED", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WIFEXITED", _keywords, &status)) goto exit; _return_value = os_WIFEXITED_impl(module, status); @@ -4429,20 +4489,20 @@ PyDoc_STRVAR(os_WEXITSTATUS__doc__, "Return the process return code from status."); #define OS_WEXITSTATUS_METHODDEF \ - {"WEXITSTATUS", (PyCFunction)os_WEXITSTATUS, METH_VARARGS|METH_KEYWORDS, os_WEXITSTATUS__doc__}, + {"WEXITSTATUS", (PyCFunction)os_WEXITSTATUS, METH_FASTCALL, os_WEXITSTATUS__doc__}, static int os_WEXITSTATUS_impl(PyModuleDef *module, int status); static PyObject * -os_WEXITSTATUS(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WEXITSTATUS(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WEXITSTATUS", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WEXITSTATUS", _keywords, &status)) goto exit; _return_value = os_WEXITSTATUS_impl(module, status); @@ -4465,20 +4525,20 @@ PyDoc_STRVAR(os_WTERMSIG__doc__, "Return the signal that terminated the process that provided the status value."); #define OS_WTERMSIG_METHODDEF \ - {"WTERMSIG", (PyCFunction)os_WTERMSIG, METH_VARARGS|METH_KEYWORDS, os_WTERMSIG__doc__}, + {"WTERMSIG", (PyCFunction)os_WTERMSIG, METH_FASTCALL, os_WTERMSIG__doc__}, static int os_WTERMSIG_impl(PyModuleDef *module, int status); static PyObject * -os_WTERMSIG(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WTERMSIG(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WTERMSIG", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WTERMSIG", _keywords, &status)) goto exit; _return_value = os_WTERMSIG_impl(module, status); @@ -4501,20 +4561,20 @@ PyDoc_STRVAR(os_WSTOPSIG__doc__, "Return the signal that stopped the process that provided the status value."); #define OS_WSTOPSIG_METHODDEF \ - {"WSTOPSIG", (PyCFunction)os_WSTOPSIG, METH_VARARGS|METH_KEYWORDS, os_WSTOPSIG__doc__}, + {"WSTOPSIG", (PyCFunction)os_WSTOPSIG, METH_FASTCALL, os_WSTOPSIG__doc__}, static int os_WSTOPSIG_impl(PyModuleDef *module, int status); static PyObject * -os_WSTOPSIG(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_WSTOPSIG(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"status", NULL}; int status; int _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WSTOPSIG", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:WSTOPSIG", _keywords, &status)) goto exit; _return_value = os_WSTOPSIG_impl(module, status); @@ -4573,19 +4633,19 @@ PyDoc_STRVAR(os_statvfs__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_STATVFS_METHODDEF \ - {"statvfs", (PyCFunction)os_statvfs, METH_VARARGS|METH_KEYWORDS, os_statvfs__doc__}, + {"statvfs", (PyCFunction)os_statvfs, METH_FASTCALL, os_statvfs__doc__}, static PyObject * os_statvfs_impl(PyModuleDef *module, path_t *path); static PyObject * -os_statvfs(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_statvfs(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", NULL}; path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:statvfs", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&:statvfs", _keywords, path_converter, &path)) goto exit; return_value = os_statvfs_impl(module, &path); @@ -4608,19 +4668,19 @@ PyDoc_STRVAR(os__getdiskusage__doc__, "Return disk usage statistics about the given path as a (total, free) tuple."); #define OS__GETDISKUSAGE_METHODDEF \ - {"_getdiskusage", (PyCFunction)os__getdiskusage, METH_VARARGS|METH_KEYWORDS, os__getdiskusage__doc__}, + {"_getdiskusage", (PyCFunction)os__getdiskusage, METH_FASTCALL, os__getdiskusage__doc__}, static PyObject * os__getdiskusage_impl(PyModuleDef *module, Py_UNICODE *path); static PyObject * -os__getdiskusage(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os__getdiskusage(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", NULL}; Py_UNICODE *path; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "u:_getdiskusage", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "u:_getdiskusage", _keywords, &path)) goto exit; return_value = os__getdiskusage_impl(module, path); @@ -4642,22 +4702,24 @@ PyDoc_STRVAR(os_fpathconf__doc__, "If there is no limit, return -1."); #define OS_FPATHCONF_METHODDEF \ - {"fpathconf", (PyCFunction)os_fpathconf, METH_VARARGS, os_fpathconf__doc__}, + {"fpathconf", (PyCFunction)os_fpathconf, METH_FASTCALL, os_fpathconf__doc__}, static long os_fpathconf_impl(PyModuleDef *module, int fd, int name); static PyObject * -os_fpathconf(PyModuleDef *module, PyObject *args) +os_fpathconf(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int name; long _return_value; - if (!PyArg_ParseTuple(args, "iO&:fpathconf", + if (!PyArg_ParseStack(stack, nargs, "iO&:fpathconf", &fd, conv_path_confname, &name)) goto exit; + if (!_PyArg_NoKeywords("fpathconf()", kwargs)) + goto exit; _return_value = os_fpathconf_impl(module, fd, name); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -4682,13 +4744,13 @@ PyDoc_STRVAR(os_pathconf__doc__, " If this functionality is unavailable, using it raises an exception."); #define OS_PATHCONF_METHODDEF \ - {"pathconf", (PyCFunction)os_pathconf, METH_VARARGS|METH_KEYWORDS, os_pathconf__doc__}, + {"pathconf", (PyCFunction)os_pathconf, METH_FASTCALL, os_pathconf__doc__}, static long os_pathconf_impl(PyModuleDef *module, path_t *path, int name); static PyObject * -os_pathconf(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_pathconf(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "name", NULL}; @@ -4696,7 +4758,7 @@ os_pathconf(PyModuleDef *module, PyObjec int name; long _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&:pathconf", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&:pathconf", _keywords, path_converter, &path, conv_path_confname, &name)) goto exit; _return_value = os_pathconf_impl(module, &path, name); @@ -4834,19 +4896,19 @@ PyDoc_STRVAR(os_device_encoding__doc__, "If the device is not a terminal, return None."); #define OS_DEVICE_ENCODING_METHODDEF \ - {"device_encoding", (PyCFunction)os_device_encoding, METH_VARARGS|METH_KEYWORDS, os_device_encoding__doc__}, + {"device_encoding", (PyCFunction)os_device_encoding, METH_FASTCALL, os_device_encoding__doc__}, static PyObject * os_device_encoding_impl(PyModuleDef *module, int fd); static PyObject * -os_device_encoding(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_device_encoding(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"fd", NULL}; int fd; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:device_encoding", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "i:device_encoding", _keywords, &fd)) goto exit; return_value = os_device_encoding_impl(module, fd); @@ -4864,22 +4926,24 @@ PyDoc_STRVAR(os_setresuid__doc__, "Set the current process\'s real, effective, and saved user ids."); #define OS_SETRESUID_METHODDEF \ - {"setresuid", (PyCFunction)os_setresuid, METH_VARARGS, os_setresuid__doc__}, + {"setresuid", (PyCFunction)os_setresuid, METH_FASTCALL, os_setresuid__doc__}, static PyObject * os_setresuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid, uid_t suid); static PyObject * -os_setresuid(PyModuleDef *module, PyObject *args) +os_setresuid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; uid_t ruid; uid_t euid; uid_t suid; - if (!PyArg_ParseTuple(args, "O&O&O&:setresuid", + if (!PyArg_ParseStack(stack, nargs, "O&O&O&:setresuid", _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) goto exit; + if (!_PyArg_NoKeywords("setresuid()", kwargs)) + goto exit; return_value = os_setresuid_impl(module, ruid, euid, suid); exit: @@ -4897,22 +4961,24 @@ PyDoc_STRVAR(os_setresgid__doc__, "Set the current process\'s real, effective, and saved group ids."); #define OS_SETRESGID_METHODDEF \ - {"setresgid", (PyCFunction)os_setresgid, METH_VARARGS, os_setresgid__doc__}, + {"setresgid", (PyCFunction)os_setresgid, METH_FASTCALL, os_setresgid__doc__}, static PyObject * os_setresgid_impl(PyModuleDef *module, gid_t rgid, gid_t egid, gid_t sgid); static PyObject * -os_setresgid(PyModuleDef *module, PyObject *args) +os_setresgid(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; gid_t rgid; gid_t egid; gid_t sgid; - if (!PyArg_ParseTuple(args, "O&O&O&:setresgid", + if (!PyArg_ParseStack(stack, nargs, "O&O&O&:setresgid", _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) goto exit; + if (!_PyArg_NoKeywords("setresgid()", kwargs)) + goto exit; return_value = os_setresgid_impl(module, rgid, egid, sgid); exit: @@ -4979,14 +5045,14 @@ PyDoc_STRVAR(os_getxattr__doc__, " the link points to."); #define OS_GETXATTR_METHODDEF \ - {"getxattr", (PyCFunction)os_getxattr, METH_VARARGS|METH_KEYWORDS, os_getxattr__doc__}, + {"getxattr", (PyCFunction)os_getxattr, METH_FASTCALL, os_getxattr__doc__}, static PyObject * os_getxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks); static PyObject * -os_getxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_getxattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "attribute", "follow_symlinks", NULL}; @@ -4994,7 +5060,7 @@ os_getxattr(PyModuleDef *module, PyObjec path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0); int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$p:getxattr", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&|$p:getxattr", _keywords, path_converter, &path, path_converter, &attribute, &follow_symlinks)) goto exit; return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); @@ -5025,14 +5091,14 @@ PyDoc_STRVAR(os_setxattr__doc__, " the link points to."); #define OS_SETXATTR_METHODDEF \ - {"setxattr", (PyCFunction)os_setxattr, METH_VARARGS|METH_KEYWORDS, os_setxattr__doc__}, + {"setxattr", (PyCFunction)os_setxattr, METH_FASTCALL, os_setxattr__doc__}, static PyObject * os_setxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, Py_buffer *value, int flags, int follow_symlinks); static PyObject * -os_setxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_setxattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; @@ -5042,7 +5108,7 @@ os_setxattr(PyModuleDef *module, PyObjec int flags = 0; int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&y*|i$p:setxattr", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&y*|i$p:setxattr", _keywords, path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks)) goto exit; return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); @@ -5075,14 +5141,14 @@ PyDoc_STRVAR(os_removexattr__doc__, " the link points to."); #define OS_REMOVEXATTR_METHODDEF \ - {"removexattr", (PyCFunction)os_removexattr, METH_VARARGS|METH_KEYWORDS, os_removexattr__doc__}, + {"removexattr", (PyCFunction)os_removexattr, METH_FASTCALL, os_removexattr__doc__}, static PyObject * os_removexattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks); static PyObject * -os_removexattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_removexattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "attribute", "follow_symlinks", NULL}; @@ -5090,7 +5156,7 @@ os_removexattr(PyModuleDef *module, PyOb path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0); int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$p:removexattr", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&O&|$p:removexattr", _keywords, path_converter, &path, path_converter, &attribute, &follow_symlinks)) goto exit; return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); @@ -5121,20 +5187,20 @@ PyDoc_STRVAR(os_listxattr__doc__, " the link points to."); #define OS_LISTXATTR_METHODDEF \ - {"listxattr", (PyCFunction)os_listxattr, METH_VARARGS|METH_KEYWORDS, os_listxattr__doc__}, + {"listxattr", (PyCFunction)os_listxattr, METH_FASTCALL, os_listxattr__doc__}, static PyObject * os_listxattr_impl(PyModuleDef *module, path_t *path, int follow_symlinks); static PyObject * -os_listxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +os_listxattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"path", "follow_symlinks", NULL}; path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1); int follow_symlinks = 1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O&$p:listxattr", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O&$p:listxattr", _keywords, path_converter, &path, &follow_symlinks)) goto exit; return_value = os_listxattr_impl(module, &path, follow_symlinks); @@ -5233,21 +5299,23 @@ PyDoc_STRVAR(os_set_inheritable__doc__, "Set the inheritable flag of the specified file descriptor."); #define OS_SET_INHERITABLE_METHODDEF \ - {"set_inheritable", (PyCFunction)os_set_inheritable, METH_VARARGS, os_set_inheritable__doc__}, + {"set_inheritable", (PyCFunction)os_set_inheritable, METH_FASTCALL, os_set_inheritable__doc__}, static PyObject * os_set_inheritable_impl(PyModuleDef *module, int fd, int inheritable); static PyObject * -os_set_inheritable(PyModuleDef *module, PyObject *args) +os_set_inheritable(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int inheritable; - if (!PyArg_ParseTuple(args, "ii:set_inheritable", + if (!PyArg_ParseStack(stack, nargs, "ii:set_inheritable", &fd, &inheritable)) goto exit; + if (!_PyArg_NoKeywords("set_inheritable()", kwargs)) + goto exit; return_value = os_set_inheritable_impl(module, fd, inheritable); exit: @@ -5297,22 +5365,24 @@ PyDoc_STRVAR(os_set_handle_inheritable__ "Set the inheritable flag of the specified handle."); #define OS_SET_HANDLE_INHERITABLE_METHODDEF \ - {"set_handle_inheritable", (PyCFunction)os_set_handle_inheritable, METH_VARARGS, os_set_handle_inheritable__doc__}, + {"set_handle_inheritable", (PyCFunction)os_set_handle_inheritable, METH_FASTCALL, os_set_handle_inheritable__doc__}, static PyObject * os_set_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle, int inheritable); static PyObject * -os_set_handle_inheritable(PyModuleDef *module, PyObject *args) +os_set_handle_inheritable(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_intptr_t handle; int inheritable; - if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "p:set_handle_inheritable", + if (!PyArg_ParseStack(stack, nargs, "" _Py_PARSE_INTPTR "p:set_handle_inheritable", &handle, &inheritable)) goto exit; + if (!_PyArg_NoKeywords("set_handle_inheritable()", kwargs)) + goto exit; return_value = os_set_handle_inheritable_impl(module, handle, inheritable); exit: @@ -5792,4 +5862,4 @@ exit: #ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF #define OS_SET_HANDLE_INHERITABLE_METHODDEF #endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ -/*[clinic end generated code: output=a5c9bef9ad11a20b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=506c1b82a68ab364 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/pyexpat.c.h --- a/Modules/clinic/pyexpat.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/pyexpat.c.h Thu May 19 13:47:42 2016 +0200 @@ -11,22 +11,24 @@ PyDoc_STRVAR(pyexpat_xmlparser_Parse__do "`isfinal\' should be true at end of input."); #define PYEXPAT_XMLPARSER_PARSE_METHODDEF \ - {"Parse", (PyCFunction)pyexpat_xmlparser_Parse, METH_VARARGS, pyexpat_xmlparser_Parse__doc__}, + {"Parse", (PyCFunction)pyexpat_xmlparser_Parse, METH_FASTCALL, pyexpat_xmlparser_Parse__doc__}, static PyObject * pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data, int isfinal); static PyObject * -pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *args) +pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *data; int isfinal = 0; - if (!PyArg_ParseTuple(args, "O|i:Parse", + if (!PyArg_ParseStack(stack, nargs, "O|i:Parse", &data, &isfinal)) goto exit; + if (!_PyArg_NoKeywords("Parse()", kwargs)) + goto exit; return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal); exit: @@ -114,7 +116,7 @@ PyDoc_STRVAR(pyexpat_xmlparser_ExternalE "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler."); #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \ - {"ExternalEntityParserCreate", (PyCFunction)pyexpat_xmlparser_ExternalEntityParserCreate, METH_VARARGS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, + {"ExternalEntityParserCreate", (PyCFunction)pyexpat_xmlparser_ExternalEntityParserCreate, METH_FASTCALL, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, static PyObject * pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, @@ -122,15 +124,17 @@ pyexpat_xmlparser_ExternalEntityParserCr const char *encoding); static PyObject * -pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args) +pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *context; const char *encoding = NULL; - if (!PyArg_ParseTuple(args, "z|s:ExternalEntityParserCreate", + if (!PyArg_ParseStack(stack, nargs, "z|s:ExternalEntityParserCreate", &context, &encoding)) goto exit; + if (!_PyArg_NoKeywords("ExternalEntityParserCreate()", kwargs)) + goto exit; return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding); exit: @@ -181,20 +185,22 @@ PyDoc_STRVAR(pyexpat_xmlparser_UseForeig "information to the parser. \'flag\' defaults to True if not provided."); #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \ - {"UseForeignDTD", (PyCFunction)pyexpat_xmlparser_UseForeignDTD, METH_VARARGS, pyexpat_xmlparser_UseForeignDTD__doc__}, + {"UseForeignDTD", (PyCFunction)pyexpat_xmlparser_UseForeignDTD, METH_FASTCALL, pyexpat_xmlparser_UseForeignDTD__doc__}, static PyObject * pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag); static PyObject * -pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *args) +pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int flag = 1; - if (!PyArg_ParseTuple(args, "|p:UseForeignDTD", + if (!PyArg_ParseStack(stack, nargs, "|p:UseForeignDTD", &flag)) goto exit; + if (!_PyArg_NoKeywords("UseForeignDTD()", kwargs)) + goto exit; return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag); exit: @@ -228,14 +234,14 @@ PyDoc_STRVAR(pyexpat_ParserCreate__doc__ "Return a new XML parser object."); #define PYEXPAT_PARSERCREATE_METHODDEF \ - {"ParserCreate", (PyCFunction)pyexpat_ParserCreate, METH_VARARGS|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, + {"ParserCreate", (PyCFunction)pyexpat_ParserCreate, METH_FASTCALL, pyexpat_ParserCreate__doc__}, static PyObject * pyexpat_ParserCreate_impl(PyModuleDef *module, const char *encoding, const char *namespace_separator, PyObject *intern); static PyObject * -pyexpat_ParserCreate(PyModuleDef *module, PyObject *args, PyObject *kwargs) +pyexpat_ParserCreate(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"encoding", "namespace_separator", "intern", NULL}; @@ -243,7 +249,7 @@ pyexpat_ParserCreate(PyModuleDef *module const char *namespace_separator = NULL; PyObject *intern = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zzO:ParserCreate", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|zzO:ParserCreate", _keywords, &encoding, &namespace_separator, &intern)) goto exit; return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern); @@ -281,4 +287,4 @@ exit: #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ -/*[clinic end generated code: output=bf4d99c9702d8a6c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=827e7eca705632b5 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/sha1module.c.h --- a/Modules/clinic/sha1module.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/sha1module.c.h Thu May 19 13:47:42 2016 +0200 @@ -72,19 +72,19 @@ PyDoc_STRVAR(_sha1_sha1__doc__, "Return a new SHA1 hash object; optionally initialized with a string."); #define _SHA1_SHA1_METHODDEF \ - {"sha1", (PyCFunction)_sha1_sha1, METH_VARARGS|METH_KEYWORDS, _sha1_sha1__doc__}, + {"sha1", (PyCFunction)_sha1_sha1, METH_FASTCALL, _sha1_sha1__doc__}, static PyObject * _sha1_sha1_impl(PyModuleDef *module, PyObject *string); static PyObject * -_sha1_sha1(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_sha1_sha1(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", NULL}; PyObject *string = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha1", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:sha1", _keywords, &string)) goto exit; return_value = _sha1_sha1_impl(module, string); @@ -92,4 +92,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=be19102f3120490a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d7aa14c8aaa91ed9 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/sha256module.c.h --- a/Modules/clinic/sha256module.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/sha256module.c.h Thu May 19 13:47:42 2016 +0200 @@ -72,19 +72,19 @@ PyDoc_STRVAR(_sha256_sha256__doc__, "Return a new SHA-256 hash object; optionally initialized with a string."); #define _SHA256_SHA256_METHODDEF \ - {"sha256", (PyCFunction)_sha256_sha256, METH_VARARGS|METH_KEYWORDS, _sha256_sha256__doc__}, + {"sha256", (PyCFunction)_sha256_sha256, METH_FASTCALL, _sha256_sha256__doc__}, static PyObject * _sha256_sha256_impl(PyModuleDef *module, PyObject *string); static PyObject * -_sha256_sha256(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_sha256_sha256(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", NULL}; PyObject *string = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha256", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:sha256", _keywords, &string)) goto exit; return_value = _sha256_sha256_impl(module, string); @@ -100,19 +100,19 @@ PyDoc_STRVAR(_sha256_sha224__doc__, "Return a new SHA-224 hash object; optionally initialized with a string."); #define _SHA256_SHA224_METHODDEF \ - {"sha224", (PyCFunction)_sha256_sha224, METH_VARARGS|METH_KEYWORDS, _sha256_sha224__doc__}, + {"sha224", (PyCFunction)_sha256_sha224, METH_FASTCALL, _sha256_sha224__doc__}, static PyObject * _sha256_sha224_impl(PyModuleDef *module, PyObject *string); static PyObject * -_sha256_sha224(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_sha256_sha224(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", NULL}; PyObject *string = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha224", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:sha224", _keywords, &string)) goto exit; return_value = _sha256_sha224_impl(module, string); @@ -120,4 +120,4 @@ static PyObject * exit: return return_value; } -/*[clinic end generated code: output=354cedf3b632c7b2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a11d9edabfbc9a25 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/sha512module.c.h --- a/Modules/clinic/sha512module.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/sha512module.c.h Thu May 19 13:47:42 2016 +0200 @@ -90,19 +90,19 @@ PyDoc_STRVAR(_sha512_sha512__doc__, "Return a new SHA-512 hash object; optionally initialized with a string."); #define _SHA512_SHA512_METHODDEF \ - {"sha512", (PyCFunction)_sha512_sha512, METH_VARARGS|METH_KEYWORDS, _sha512_sha512__doc__}, + {"sha512", (PyCFunction)_sha512_sha512, METH_FASTCALL, _sha512_sha512__doc__}, static PyObject * _sha512_sha512_impl(PyModuleDef *module, PyObject *string); static PyObject * -_sha512_sha512(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_sha512_sha512(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", NULL}; PyObject *string = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha512", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:sha512", _keywords, &string)) goto exit; return_value = _sha512_sha512_impl(module, string); @@ -122,19 +122,19 @@ PyDoc_STRVAR(_sha512_sha384__doc__, "Return a new SHA-384 hash object; optionally initialized with a string."); #define _SHA512_SHA384_METHODDEF \ - {"sha384", (PyCFunction)_sha512_sha384, METH_VARARGS|METH_KEYWORDS, _sha512_sha384__doc__}, + {"sha384", (PyCFunction)_sha512_sha384, METH_FASTCALL, _sha512_sha384__doc__}, static PyObject * _sha512_sha384_impl(PyModuleDef *module, PyObject *string); static PyObject * -_sha512_sha384(PyModuleDef *module, PyObject *args, PyObject *kwargs) +_sha512_sha384(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"string", NULL}; PyObject *string = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha384", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|O:sha384", _keywords, &string)) goto exit; return_value = _sha512_sha384_impl(module, string); @@ -168,4 +168,4 @@ exit: #ifndef _SHA512_SHA384_METHODDEF #define _SHA512_SHA384_METHODDEF #endif /* !defined(_SHA512_SHA384_METHODDEF) */ -/*[clinic end generated code: output=1c7d385731fee7c0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8b3064dfaf27bcaf input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/signalmodule.c.h --- a/Modules/clinic/signalmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/signalmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -72,21 +72,23 @@ PyDoc_STRVAR(signal_signal__doc__, "the first is the signal number, the second is the interrupted stack frame."); #define SIGNAL_SIGNAL_METHODDEF \ - {"signal", (PyCFunction)signal_signal, METH_VARARGS, signal_signal__doc__}, + {"signal", (PyCFunction)signal_signal, METH_FASTCALL, signal_signal__doc__}, static PyObject * signal_signal_impl(PyModuleDef *module, int signalnum, PyObject *handler); static PyObject * -signal_signal(PyModuleDef *module, PyObject *args) +signal_signal(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int signalnum; PyObject *handler; - if (!PyArg_ParseTuple(args, "iO:signal", + if (!PyArg_ParseStack(stack, nargs, "iO:signal", &signalnum, &handler)) goto exit; + if (!_PyArg_NoKeywords("signal()", kwargs)) + goto exit; return_value = signal_signal_impl(module, signalnum, handler); exit: @@ -137,21 +139,23 @@ PyDoc_STRVAR(signal_siginterrupt__doc__, "signal sig, else system calls will be interrupted."); #define SIGNAL_SIGINTERRUPT_METHODDEF \ - {"siginterrupt", (PyCFunction)signal_siginterrupt, METH_VARARGS, signal_siginterrupt__doc__}, + {"siginterrupt", (PyCFunction)signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__}, static PyObject * signal_siginterrupt_impl(PyModuleDef *module, int signalnum, int flag); static PyObject * -signal_siginterrupt(PyModuleDef *module, PyObject *args) +signal_siginterrupt(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int signalnum; int flag; - if (!PyArg_ParseTuple(args, "ii:siginterrupt", + if (!PyArg_ParseStack(stack, nargs, "ii:siginterrupt", &signalnum, &flag)) goto exit; + if (!_PyArg_NoKeywords("siginterrupt()", kwargs)) + goto exit; return_value = signal_siginterrupt_impl(module, signalnum, flag); exit: @@ -174,23 +178,25 @@ PyDoc_STRVAR(signal_setitimer__doc__, "Returns old values as a tuple: (delay, interval)."); #define SIGNAL_SETITIMER_METHODDEF \ - {"setitimer", (PyCFunction)signal_setitimer, METH_VARARGS, signal_setitimer__doc__}, + {"setitimer", (PyCFunction)signal_setitimer, METH_FASTCALL, signal_setitimer__doc__}, static PyObject * signal_setitimer_impl(PyModuleDef *module, int which, double seconds, double interval); static PyObject * -signal_setitimer(PyModuleDef *module, PyObject *args) +signal_setitimer(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int which; double seconds; double interval = 0.0; - if (!PyArg_ParseTuple(args, "id|d:setitimer", + if (!PyArg_ParseStack(stack, nargs, "id|d:setitimer", &which, &seconds, &interval)) goto exit; + if (!_PyArg_NoKeywords("setitimer()", kwargs)) + goto exit; return_value = signal_setitimer_impl(module, which, seconds, interval); exit: @@ -238,21 +244,23 @@ PyDoc_STRVAR(signal_pthread_sigmask__doc "Fetch and/or change the signal mask of the calling thread."); #define SIGNAL_PTHREAD_SIGMASK_METHODDEF \ - {"pthread_sigmask", (PyCFunction)signal_pthread_sigmask, METH_VARARGS, signal_pthread_sigmask__doc__}, + {"pthread_sigmask", (PyCFunction)signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__}, static PyObject * signal_pthread_sigmask_impl(PyModuleDef *module, int how, PyObject *mask); static PyObject * -signal_pthread_sigmask(PyModuleDef *module, PyObject *args) +signal_pthread_sigmask(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int how; PyObject *mask; - if (!PyArg_ParseTuple(args, "iO:pthread_sigmask", + if (!PyArg_ParseStack(stack, nargs, "iO:pthread_sigmask", &how, &mask)) goto exit; + if (!_PyArg_NoKeywords("pthread_sigmask()", kwargs)) + goto exit; return_value = signal_pthread_sigmask_impl(module, how, mask); exit: @@ -329,23 +337,25 @@ PyDoc_STRVAR(signal_sigtimedwait__doc__, "The timeout is specified in seconds, with floating point numbers allowed."); #define SIGNAL_SIGTIMEDWAIT_METHODDEF \ - {"sigtimedwait", (PyCFunction)signal_sigtimedwait, METH_VARARGS, signal_sigtimedwait__doc__}, + {"sigtimedwait", (PyCFunction)signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__}, static PyObject * signal_sigtimedwait_impl(PyModuleDef *module, PyObject *sigset, PyObject *timeout_obj); static PyObject * -signal_sigtimedwait(PyModuleDef *module, PyObject *args) +signal_sigtimedwait(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *sigset; PyObject *timeout_obj; - if (!PyArg_UnpackTuple(args, "sigtimedwait", + if (!PyArg_UnpackStack(stack, nargs, "sigtimedwait", 2, 2, &sigset, &timeout_obj)) goto exit; + if (!_PyArg_NoKeywords("sigtimedwait", kwargs)) + goto exit; return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj); exit: @@ -363,21 +373,23 @@ PyDoc_STRVAR(signal_pthread_kill__doc__, "Send a signal to a thread."); #define SIGNAL_PTHREAD_KILL_METHODDEF \ - {"pthread_kill", (PyCFunction)signal_pthread_kill, METH_VARARGS, signal_pthread_kill__doc__}, + {"pthread_kill", (PyCFunction)signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__}, static PyObject * signal_pthread_kill_impl(PyModuleDef *module, long thread_id, int signalnum); static PyObject * -signal_pthread_kill(PyModuleDef *module, PyObject *args) +signal_pthread_kill(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; long thread_id; int signalnum; - if (!PyArg_ParseTuple(args, "li:pthread_kill", + if (!PyArg_ParseStack(stack, nargs, "li:pthread_kill", &thread_id, &signalnum)) goto exit; + if (!_PyArg_NoKeywords("pthread_kill()", kwargs)) + goto exit; return_value = signal_pthread_kill_impl(module, thread_id, signalnum); exit: @@ -429,4 +441,4 @@ exit: #ifndef SIGNAL_PTHREAD_KILL_METHODDEF #define SIGNAL_PTHREAD_KILL_METHODDEF #endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */ -/*[clinic end generated code: output=b99278c16c40ea43 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=26b6ac68fed18b3a input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/unicodedata.c.h --- a/Modules/clinic/unicodedata.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/unicodedata.c.h Thu May 19 13:47:42 2016 +0200 @@ -13,22 +13,24 @@ PyDoc_STRVAR(unicodedata_UCD_decimal__do "ValueError is raised."); #define UNICODEDATA_UCD_DECIMAL_METHODDEF \ - {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_VARARGS, unicodedata_UCD_decimal__doc__}, + {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_FASTCALL, unicodedata_UCD_decimal__doc__}, static PyObject * unicodedata_UCD_decimal_impl(PyObject *self, int chr, PyObject *default_value); static PyObject * -unicodedata_UCD_decimal(PyObject *self, PyObject *args) +unicodedata_UCD_decimal(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int chr; PyObject *default_value = NULL; - if (!PyArg_ParseTuple(args, "C|O:decimal", + if (!PyArg_ParseStack(stack, nargs, "C|O:decimal", &chr, &default_value)) goto exit; + if (!_PyArg_NoKeywords("decimal()", kwargs)) + goto exit; return_value = unicodedata_UCD_decimal_impl(self, chr, default_value); exit: @@ -46,21 +48,23 @@ PyDoc_STRVAR(unicodedata_UCD_digit__doc_ "ValueError is raised."); #define UNICODEDATA_UCD_DIGIT_METHODDEF \ - {"digit", (PyCFunction)unicodedata_UCD_digit, METH_VARARGS, unicodedata_UCD_digit__doc__}, + {"digit", (PyCFunction)unicodedata_UCD_digit, METH_FASTCALL, unicodedata_UCD_digit__doc__}, static PyObject * unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value); static PyObject * -unicodedata_UCD_digit(PyObject *self, PyObject *args) +unicodedata_UCD_digit(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int chr; PyObject *default_value = NULL; - if (!PyArg_ParseTuple(args, "C|O:digit", + if (!PyArg_ParseStack(stack, nargs, "C|O:digit", &chr, &default_value)) goto exit; + if (!_PyArg_NoKeywords("digit()", kwargs)) + goto exit; return_value = unicodedata_UCD_digit_impl(self, chr, default_value); exit: @@ -78,22 +82,24 @@ PyDoc_STRVAR(unicodedata_UCD_numeric__do "ValueError is raised."); #define UNICODEDATA_UCD_NUMERIC_METHODDEF \ - {"numeric", (PyCFunction)unicodedata_UCD_numeric, METH_VARARGS, unicodedata_UCD_numeric__doc__}, + {"numeric", (PyCFunction)unicodedata_UCD_numeric, METH_FASTCALL, unicodedata_UCD_numeric__doc__}, static PyObject * unicodedata_UCD_numeric_impl(PyObject *self, int chr, PyObject *default_value); static PyObject * -unicodedata_UCD_numeric(PyObject *self, PyObject *args) +unicodedata_UCD_numeric(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int chr; PyObject *default_value = NULL; - if (!PyArg_ParseTuple(args, "C|O:numeric", + if (!PyArg_ParseStack(stack, nargs, "C|O:numeric", &chr, &default_value)) goto exit; + if (!_PyArg_NoKeywords("numeric()", kwargs)) + goto exit; return_value = unicodedata_UCD_numeric_impl(self, chr, default_value); exit: @@ -282,22 +288,24 @@ PyDoc_STRVAR(unicodedata_UCD_normalize__ "Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'."); #define UNICODEDATA_UCD_NORMALIZE_METHODDEF \ - {"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_VARARGS, unicodedata_UCD_normalize__doc__}, + {"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_FASTCALL, unicodedata_UCD_normalize__doc__}, static PyObject * unicodedata_UCD_normalize_impl(PyObject *self, const char *form, PyObject *input); static PyObject * -unicodedata_UCD_normalize(PyObject *self, PyObject *args) +unicodedata_UCD_normalize(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; const char *form; PyObject *input; - if (!PyArg_ParseTuple(args, "sO!:normalize", + if (!PyArg_ParseStack(stack, nargs, "sO!:normalize", &form, &PyUnicode_Type, &input)) goto exit; + if (!_PyArg_NoKeywords("normalize()", kwargs)) + goto exit; return_value = unicodedata_UCD_normalize_impl(self, form, input); exit: @@ -314,21 +322,23 @@ PyDoc_STRVAR(unicodedata_UCD_name__doc__ "ValueError is raised."); #define UNICODEDATA_UCD_NAME_METHODDEF \ - {"name", (PyCFunction)unicodedata_UCD_name, METH_VARARGS, unicodedata_UCD_name__doc__}, + {"name", (PyCFunction)unicodedata_UCD_name, METH_FASTCALL, unicodedata_UCD_name__doc__}, static PyObject * unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value); static PyObject * -unicodedata_UCD_name(PyObject *self, PyObject *args) +unicodedata_UCD_name(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int chr; PyObject *default_value = NULL; - if (!PyArg_ParseTuple(args, "C|O:name", + if (!PyArg_ParseStack(stack, nargs, "C|O:name", &chr, &default_value)) goto exit; + if (!_PyArg_NoKeywords("name()", kwargs)) + goto exit; return_value = unicodedata_UCD_name_impl(self, chr, default_value); exit: @@ -365,4 +375,4 @@ unicodedata_UCD_lookup(PyObject *self, P exit: return return_value; } -/*[clinic end generated code: output=4f8da33c6bc6efc9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d8dc8d6fe22877d8 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/clinic/zlibmodule.c.h --- a/Modules/clinic/zlibmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/clinic/zlibmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -14,20 +14,20 @@ PyDoc_STRVAR(zlib_compress__doc__, " Compression level, in 0-9 or -1."); #define ZLIB_COMPRESS_METHODDEF \ - {"compress", (PyCFunction)zlib_compress, METH_VARARGS|METH_KEYWORDS, zlib_compress__doc__}, + {"compress", (PyCFunction)zlib_compress, METH_FASTCALL, zlib_compress__doc__}, static PyObject * zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level); static PyObject * -zlib_compress(PyModuleDef *module, PyObject *args, PyObject *kwargs) +zlib_compress(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"data", "level", NULL}; Py_buffer data = {NULL, NULL}; int level = Z_DEFAULT_COMPRESSION; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:compress", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "y*|i:compress", _keywords, &data, &level)) goto exit; return_value = zlib_compress_impl(module, &data, level); @@ -54,23 +54,25 @@ PyDoc_STRVAR(zlib_decompress__doc__, " The initial output buffer size."); #define ZLIB_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)zlib_decompress, METH_VARARGS, zlib_decompress__doc__}, + {"decompress", (PyCFunction)zlib_decompress, METH_FASTCALL, zlib_decompress__doc__}, static PyObject * zlib_decompress_impl(PyModuleDef *module, Py_buffer *data, int wbits, unsigned int bufsize); static PyObject * -zlib_decompress(PyModuleDef *module, PyObject *args) +zlib_decompress(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; int wbits = MAX_WBITS; unsigned int bufsize = DEF_BUF_SIZE; - if (!PyArg_ParseTuple(args, "y*|iO&:decompress", + if (!PyArg_ParseStack(stack, nargs, "y*|iO&:decompress", &data, &wbits, capped_uint_converter, &bufsize)) goto exit; + if (!_PyArg_NoKeywords("decompress()", kwargs)) + goto exit; return_value = zlib_decompress_impl(module, &data, wbits, bufsize); exit: @@ -109,14 +111,14 @@ PyDoc_STRVAR(zlib_compressobj__doc__, " containing subsequences that are likely to occur in the input data."); #define ZLIB_COMPRESSOBJ_METHODDEF \ - {"compressobj", (PyCFunction)zlib_compressobj, METH_VARARGS|METH_KEYWORDS, zlib_compressobj__doc__}, + {"compressobj", (PyCFunction)zlib_compressobj, METH_FASTCALL, zlib_compressobj__doc__}, static PyObject * zlib_compressobj_impl(PyModuleDef *module, int level, int method, int wbits, int memLevel, int strategy, Py_buffer *zdict); static PyObject * -zlib_compressobj(PyModuleDef *module, PyObject *args, PyObject *kwargs) +zlib_compressobj(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"level", "method", "wbits", "memLevel", "strategy", "zdict", NULL}; @@ -127,7 +129,7 @@ zlib_compressobj(PyModuleDef *module, Py int strategy = Z_DEFAULT_STRATEGY; Py_buffer zdict = {NULL, NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiiiiy*:compressobj", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|iiiiiy*:compressobj", _keywords, &level, &method, &wbits, &memLevel, &strategy, &zdict)) goto exit; return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict); @@ -153,20 +155,20 @@ PyDoc_STRVAR(zlib_decompressobj__doc__, " dictionary as used by the compressor that produced the input data."); #define ZLIB_DECOMPRESSOBJ_METHODDEF \ - {"decompressobj", (PyCFunction)zlib_decompressobj, METH_VARARGS|METH_KEYWORDS, zlib_decompressobj__doc__}, + {"decompressobj", (PyCFunction)zlib_decompressobj, METH_FASTCALL, zlib_decompressobj__doc__}, static PyObject * zlib_decompressobj_impl(PyModuleDef *module, int wbits, PyObject *zdict); static PyObject * -zlib_decompressobj(PyModuleDef *module, PyObject *args, PyObject *kwargs) +zlib_decompressobj(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"wbits", "zdict", NULL}; int wbits = MAX_WBITS; PyObject *zdict = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iO:decompressobj", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|iO:decompressobj", _keywords, &wbits, &zdict)) goto exit; return_value = zlib_decompressobj_impl(module, wbits, zdict); @@ -230,22 +232,24 @@ PyDoc_STRVAR(zlib_Decompress_decompress_ "Call the flush() method to clear these buffers."); #define ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \ - {"decompress", (PyCFunction)zlib_Decompress_decompress, METH_VARARGS, zlib_Decompress_decompress__doc__}, + {"decompress", (PyCFunction)zlib_Decompress_decompress, METH_FASTCALL, zlib_Decompress_decompress__doc__}, static PyObject * zlib_Decompress_decompress_impl(compobject *self, Py_buffer *data, unsigned int max_length); static PyObject * -zlib_Decompress_decompress(compobject *self, PyObject *args) +zlib_Decompress_decompress(compobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; unsigned int max_length = 0; - if (!PyArg_ParseTuple(args, "y*|O&:decompress", + if (!PyArg_ParseStack(stack, nargs, "y*|O&:decompress", &data, capped_uint_converter, &max_length)) goto exit; + if (!_PyArg_NoKeywords("decompress()", kwargs)) + goto exit; return_value = zlib_Decompress_decompress_impl(self, &data, max_length); exit: @@ -269,20 +273,22 @@ PyDoc_STRVAR(zlib_Compress_flush__doc__, " can still be compressed."); #define ZLIB_COMPRESS_FLUSH_METHODDEF \ - {"flush", (PyCFunction)zlib_Compress_flush, METH_VARARGS, zlib_Compress_flush__doc__}, + {"flush", (PyCFunction)zlib_Compress_flush, METH_FASTCALL, zlib_Compress_flush__doc__}, static PyObject * zlib_Compress_flush_impl(compobject *self, int mode); static PyObject * -zlib_Compress_flush(compobject *self, PyObject *args) +zlib_Compress_flush(compobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int mode = Z_FINISH; - if (!PyArg_ParseTuple(args, "|i:flush", + if (!PyArg_ParseStack(stack, nargs, "|i:flush", &mode)) goto exit; + if (!_PyArg_NoKeywords("flush()", kwargs)) + goto exit; return_value = zlib_Compress_flush_impl(self, mode); exit: @@ -343,20 +349,22 @@ PyDoc_STRVAR(zlib_Decompress_flush__doc_ " the initial size of the output buffer."); #define ZLIB_DECOMPRESS_FLUSH_METHODDEF \ - {"flush", (PyCFunction)zlib_Decompress_flush, METH_VARARGS, zlib_Decompress_flush__doc__}, + {"flush", (PyCFunction)zlib_Decompress_flush, METH_FASTCALL, zlib_Decompress_flush__doc__}, static PyObject * zlib_Decompress_flush_impl(compobject *self, unsigned int length); static PyObject * -zlib_Decompress_flush(compobject *self, PyObject *args) +zlib_Decompress_flush(compobject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; unsigned int length = DEF_BUF_SIZE; - if (!PyArg_ParseTuple(args, "|O&:flush", + if (!PyArg_ParseStack(stack, nargs, "|O&:flush", capped_uint_converter, &length)) goto exit; + if (!_PyArg_NoKeywords("flush()", kwargs)) + goto exit; return_value = zlib_Decompress_flush_impl(self, length); exit: @@ -375,21 +383,23 @@ PyDoc_STRVAR(zlib_adler32__doc__, "The returned checksum is an integer."); #define ZLIB_ADLER32_METHODDEF \ - {"adler32", (PyCFunction)zlib_adler32, METH_VARARGS, zlib_adler32__doc__}, + {"adler32", (PyCFunction)zlib_adler32, METH_FASTCALL, zlib_adler32__doc__}, static PyObject * zlib_adler32_impl(PyModuleDef *module, Py_buffer *data, unsigned int value); static PyObject * -zlib_adler32(PyModuleDef *module, PyObject *args) +zlib_adler32(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; unsigned int value = 1; - if (!PyArg_ParseTuple(args, "y*|I:adler32", + if (!PyArg_ParseStack(stack, nargs, "y*|I:adler32", &data, &value)) goto exit; + if (!_PyArg_NoKeywords("adler32()", kwargs)) + goto exit; return_value = zlib_adler32_impl(module, &data, value); exit: @@ -412,21 +422,23 @@ PyDoc_STRVAR(zlib_crc32__doc__, "The returned checksum is an integer."); #define ZLIB_CRC32_METHODDEF \ - {"crc32", (PyCFunction)zlib_crc32, METH_VARARGS, zlib_crc32__doc__}, + {"crc32", (PyCFunction)zlib_crc32, METH_FASTCALL, zlib_crc32__doc__}, static PyObject * zlib_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int value); static PyObject * -zlib_crc32(PyModuleDef *module, PyObject *args) +zlib_crc32(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; unsigned int value = 0; - if (!PyArg_ParseTuple(args, "y*|I:crc32", + if (!PyArg_ParseStack(stack, nargs, "y*|I:crc32", &data, &value)) goto exit; + if (!_PyArg_NoKeywords("crc32()", kwargs)) + goto exit; return_value = zlib_crc32_impl(module, &data, value); exit: @@ -440,4 +452,4 @@ exit: #ifndef ZLIB_COMPRESS_COPY_METHODDEF #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -/*[clinic end generated code: output=e6f3b79e051ecc35 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=468b162219c80707 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/itertoolsmodule.c Thu May 19 13:47:42 2016 +0200 @@ -1386,21 +1386,19 @@ typedef struct { static PyTypeObject islice_type; static PyObject * -islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +islice_new(PyTypeObject *type, PyObject **stack, int numargs, PyObject *kwds) { PyObject *seq; Py_ssize_t start=0, stop=-1, step=1; PyObject *it, *a1=NULL, *a2=NULL, *a3=NULL; - Py_ssize_t numargs; isliceobject *lz; - if (type == &islice_type && !_PyArg_NoKeywords("islice()", kwds)) + if (type == &islice_type && kwds != NULL && !_PyArg_NoKeywords("islice()", kwds)) return NULL; - if (!PyArg_UnpackTuple(args, "islice", 2, 4, &seq, &a1, &a2, &a3)) + if (!PyArg_UnpackStack(stack, numargs, "islice", 2, 4, &seq, &a1, &a2, &a3)) return NULL; - numargs = PyTuple_Size(args); if (numargs == 2) { if (a1 != Py_None) { stop = PyLong_AsSsize_t(a1); @@ -1608,7 +1606,7 @@ static PyTypeObject islice_type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_FASTNEW, /* tp_flags */ islice_doc, /* tp_doc */ (traverseproc)islice_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -1626,7 +1624,7 @@ static PyTypeObject islice_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - islice_new, /* tp_new */ + (newfunc)islice_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -3904,7 +3902,7 @@ slow_mode: when cnt == PY_SSIZE_T_MAX, static PyTypeObject count_type; static PyObject * -count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +count_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { countobject *lz; int slow_mode = 0; @@ -3914,7 +3912,7 @@ count_new(PyTypeObject *type, PyObject * long step; static char *kwlist[] = {"start", "step", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:count", + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|OO:count", kwlist, &long_cnt, &long_step)) return NULL; @@ -4093,7 +4091,7 @@ static PyTypeObject count_type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_FASTNEW, /* tp_flags */ count_doc, /* tp_doc */ (traverseproc)count_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -4111,7 +4109,7 @@ static PyTypeObject count_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - count_new, /* tp_new */ + (newfunc)count_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Modules/main.c --- a/Modules/main.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/main.c Thu May 19 13:47:42 2016 +0200 @@ -156,7 +156,7 @@ static void RunInteractiveHook(void) if (hook == NULL) PyErr_Clear(); else { - result = PyObject_CallObject(hook, NULL); + result = PyObject_CallNoArg(hook); Py_DECREF(hook); if (result == NULL) goto error; diff -r 496e094f4734 -r 34456cce64bb Modules/pyexpat.c --- a/Modules/pyexpat.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/pyexpat.c Thu May 19 13:47:42 2016 +0200 @@ -223,7 +223,8 @@ call_with_frame(const char *funcname, in { PyObject *res; - res = PyEval_CallObject(func, args); + /* FIXME: fast call */ + res = PyObject_Call(func, args, NULL); if (res == NULL) { _PyTraceback_Add(funcname, __FILE__, lineno); XML_StopParser(self->itself, XML_FALSE); diff -r 496e094f4734 -r 34456cce64bb Modules/signalmodule.c --- a/Modules/signalmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/signalmodule.c Thu May 19 13:47:42 2016 +0200 @@ -1571,15 +1571,10 @@ PyErr_CheckSignals(void) for (i = 1; i < NSIG; i++) { if (Handlers[i].tripped) { - PyObject *result = NULL; - PyObject *arglist = Py_BuildValue("(iO)", i, f); + PyObject *result; Handlers[i].tripped = 0; - if (arglist) { - result = PyEval_CallObject(Handlers[i].func, - arglist); - Py_DECREF(arglist); - } + result = PyObject_CallFunction(Handlers[i].func, "(iO)", i, f); if (!result) return -1; diff -r 496e094f4734 -r 34456cce64bb Modules/xxsubtype.c --- a/Modules/xxsubtype.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Modules/xxsubtype.c Thu May 19 13:47:42 2016 +0200 @@ -82,7 +82,7 @@ static PyMethodDef spamlist_methods[] = static int spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds) { - if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0) + if (_PyType_CallInit(&PyList_Type, (PyObject *)self, args, kwds) < 0) return -1; self->state = 0; return 0; @@ -179,7 +179,7 @@ static PyMethodDef spamdict_methods[] = static int spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds) { - if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0) + if (_PyType_CallInit(&PyDict_Type, (PyObject *)self, args, kwds) < 0) return -1; self->state = 0; return 0; diff -r 496e094f4734 -r 34456cce64bb Objects/abstract.c --- a/Objects/abstract.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/abstract.c Thu May 19 13:47:42 2016 +0200 @@ -5,8 +5,6 @@ #include "structmember.h" /* we need the offsetof() macro from there */ #include "longintrepr.h" - - /* Shorthands to return certain errors */ static PyObject * @@ -1285,7 +1283,7 @@ PyNumber_Long(PyObject *o) } trunc_func = _PyObject_LookupSpecial(o, &PyId___trunc__); if (trunc_func) { - PyObject *truncated = PyEval_CallObject(trunc_func, NULL); + PyObject *truncated = PyObject_CallNoArg(trunc_func); PyObject *int_instance; Py_DECREF(trunc_func); if (truncated == NULL || PyLong_Check(truncated)) @@ -2091,9 +2089,14 @@ PyMapping_Values(PyObject *o) /* XXX PyCallable_Check() is in object.c */ PyObject * -PyObject_CallObject(PyObject *o, PyObject *a) +PyObject_CallObject(PyObject *func, PyObject *args) { - return PyEval_CallObjectWithKeywords(o, a, NULL); + if (args != NULL) { + return PyObject_Call(func, args, NULL); + } + else { + return PyObject_CallNoArg(func); + } } PyObject* @@ -2147,136 +2150,220 @@ PyObject* } PyObject * -PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) +PyObject_Call(PyObject *func, PyObject *args, PyObject *kwargs) { - ternaryfunc call; - PyObject *result; + PyObject *result = NULL; /* PyObject_Call() must not be called with an exception set, because it may clear it (directly or indirectly) and so the caller loses its exception */ assert(!PyErr_Occurred()); - call = func->ob_type->tp_call; - if (call == NULL) { - PyErr_Format(PyExc_TypeError, "'%.200s' object is not callable", - func->ob_type->tp_name); + if (Py_EnterRecursiveCall(" while calling a Python object")) { return NULL; } - if (Py_EnterRecursiveCall(" while calling a Python object")) + if (PyCFunction_Check(func)) { + /* Use _PyCFunction_FastCall_FromArgs() to avoid unpack+pack + the argument tuple for METH_VARARGS */ + result = _PyCFunction_FastCall_FromArgs(func, args, kwargs); + } + else if (Py_TYPE(func)->tp_flags & Py_TPFLAGS_FASTCALL) { + fastternaryfunc fastcall; + PyObject **stack; + int nargs; + + fastcall = (fastternaryfunc)Py_TYPE(func)->tp_call; + stack = _PyStack_FromBorrowedTuple(args, 0, &nargs); + + result = fastcall(func, stack, nargs, kwargs); + result = _Py_CheckFunctionResult(func, result, NULL); + } + else { + ternaryfunc call = func->ob_type->tp_call; + if (call == NULL) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not callable", + func->ob_type->tp_name); + goto exit; + } + + result = (*call)(func, args, kwargs); + result = _Py_CheckFunctionResult(func, result, NULL); + } + +exit: + Py_LeaveRecursiveCall(); + return result; +} + +PyObject * +_PyObject_FastCall(PyObject *func, PyObject **stack, int nargs, PyObject *kwargs) +{ + ternaryfunc call; + PyObject *args, *result = NULL; + + /* _PyObject_FastCall() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + + assert(func != NULL); + assert(nargs >= 0); + assert(nargs == 0 || stack != NULL); + assert(kwargs == NULL || PyDict_Check(kwargs)); + + if (Py_EnterRecursiveCall(" while calling a Python object")) { return NULL; - - result = (*call)(func, arg, kw); - + } + + if (Py_TYPE(func)->tp_flags & Py_TPFLAGS_FASTCALL) { + fastternaryfunc fastcall = (fastternaryfunc)Py_TYPE(func)->tp_call; + + result = fastcall(func, stack, nargs, kwargs); + } + else { + /* Slow-path: build a temporary tuple */ + call = func->ob_type->tp_call; + if (call == NULL) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not callable", + func->ob_type->tp_name); + goto exit; + } + + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + goto exit; + } + + result = (*call)(func, args, kwargs); + Py_DECREF(args); + } + + result = _Py_CheckFunctionResult(func, result, NULL); + +exit: Py_LeaveRecursiveCall(); - return _Py_CheckFunctionResult(func, result, NULL); + return result; } -static PyObject* -call_function_tail(PyObject *callable, PyObject *args) +PyObject * +PyObject_CallNoArg(PyObject *func) { - PyObject *retval; - - if (args == NULL) + return _PyObject_FastCall(func, NULL, 0, 0); +} + +PyObject * +PyObject_CallArg1(PyObject *func, PyObject *arg) +{ + PyObject *result; + + /* should we hold a reference? */ + Py_INCREF(arg); + result = _PyObject_FastCall(func, &arg, 1, 0); + Py_DECREF(arg); + return result; +} + +PyObject * +_PyObject_CallVaFunction(PyObject *callable, const char *format, va_list vargs) +{ + int nargs; + PyObject* small_stack[_PyStack_SIZE]; + PyObject **stack; + PyObject *result; + + if (callable == NULL) { + return null_error(); + } + + stack = Py_VaBuildStack(small_stack, Py_ARRAY_LENGTH(small_stack), + &nargs, format, vargs); + if (stack == NULL) { return NULL; - - if (!PyTuple_Check(args)) { - PyObject *a; - - a = PyTuple_New(1); - if (a == NULL) { - Py_DECREF(args); - return NULL; - } - PyTuple_SET_ITEM(a, 0, args); - args = a; } - retval = PyObject_Call(callable, args, NULL); - - Py_DECREF(args); - - return retval; + + result = _PyObject_FastCall(callable, stack, nargs, NULL); + _PyStack_Free(stack, small_stack, nargs); + return result; } PyObject * PyObject_CallFunction(PyObject *callable, const char *format, ...) { - va_list va; - PyObject *args; - - if (callable == NULL) - return null_error(); - - if (format && *format) { - va_start(va, format); - args = Py_VaBuildValue(format, va); - va_end(va); - } - else - args = PyTuple_New(0); - if (args == NULL) - return NULL; - - return call_function_tail(callable, args); + va_list vargs; + PyObject *result; + + va_start(vargs, format); + result = _PyObject_CallVaFunction(callable, format, vargs); + va_end(vargs); + + return result; } PyObject * _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...) { va_list va; - PyObject *args; + PyObject **stack; + int na; + PyObject *result; + PyObject* small_stack[_PyStack_SIZE]; if (callable == NULL) return null_error(); - if (format && *format) { - va_start(va, format); - args = _Py_VaBuildValue_SizeT(format, va); - va_end(va); + va_start(va, format); + stack = _Py_VaBuildStack_SizeT(small_stack, Py_ARRAY_LENGTH(small_stack), + &na, format, va); + va_end(va); + + if (stack == NULL) { + return NULL; } - else - args = PyTuple_New(0); - - return call_function_tail(callable, args); + + result = _PyObject_FastCall(callable, stack, na, NULL); + _PyStack_Free(stack, small_stack, na); + return result; } static PyObject* callmethod(PyObject* func, const char *format, va_list va, int is_size_t) { - PyObject *retval = NULL; - PyObject *args; + PyObject **stack; + int na; + PyObject *result; + PyObject* small_stack[_PyStack_SIZE]; if (!PyCallable_Check(func)) { type_error("attribute of type '%.200s' is not callable", func); - goto exit; + return NULL; } - if (format && *format) { - if (is_size_t) - args = _Py_VaBuildValue_SizeT(format, va); - else - args = Py_VaBuildValue(format, va); + if (is_size_t) { + stack = _Py_VaBuildStack_SizeT(small_stack, + Py_ARRAY_LENGTH(small_stack), + &na, format, va); } - else - args = PyTuple_New(0); - - retval = call_function_tail(func, args); - - exit: - /* args gets consumed in call_function_tail */ - Py_XDECREF(func); - - return retval; + else { + stack = Py_VaBuildStack(small_stack, Py_ARRAY_LENGTH(small_stack), + &na, format, va); + } + if (stack == NULL) { + return NULL; + } + + result = _PyObject_FastCall(func, stack, na, NULL); + _PyStack_Free(stack, small_stack, na); + + return result; } PyObject * -PyObject_CallMethod(PyObject *o, const char *name, const char *format, ...) +_PyObject_CallVaMethod(PyObject *o, const char *name, + const char *format, va_list vargs) { - va_list va; - PyObject *func = NULL; - PyObject *retval = NULL; + PyObject *func, *result; if (o == NULL || name == NULL) return null_error(); @@ -2285,10 +2372,22 @@ PyObject_CallMethod(PyObject *o, const c if (func == NULL) return NULL; - va_start(va, format); - retval = callmethod(func, format, va, 0); - va_end(va); - return retval; + result = callmethod(func, format, vargs, 0); + Py_DECREF(func); + return result; +} + +PyObject * +PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...) +{ + va_list vargs; + PyObject *result; + + va_start(vargs, format); + result = _PyObject_CallVaMethod(obj, name, format, vargs); + va_end(vargs); + + return result; } PyObject * @@ -2308,6 +2407,7 @@ PyObject * va_start(va, format); retval = callmethod(func, format, va, 0); + Py_DECREF(func); va_end(va); return retval; } @@ -2328,6 +2428,7 @@ PyObject * return NULL; va_start(va, format); retval = callmethod(func, format, va, 1); + Py_DECREF(func); va_end(va); return retval; } @@ -2349,108 +2450,100 @@ PyObject * } va_start(va, format); retval = callmethod(func, format, va, 1); + Py_DECREF(func); va_end(va); return retval; } -static PyObject * -objargs_mktuple(va_list va) -{ - int i, n = 0; - va_list countva; - PyObject *result, *tmp; - - Py_VA_COPY(countva, va); - - while (((PyObject *)va_arg(countva, PyObject *)) != NULL) - ++n; - result = PyTuple_New(n); - if (result != NULL && n > 0) { - for (i = 0; i < n; ++i) { - tmp = (PyObject *)va_arg(va, PyObject *); - PyTuple_SET_ITEM(result, i, tmp); - Py_INCREF(tmp); - } - } - return result; -} - PyObject * PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...) { - PyObject *args, *tmp; + PyObject *func; va_list vargs; + int na; + PyObject **stack; + PyObject *result; + PyObject* small_stack[_PyStack_SIZE]; if (callable == NULL || name == NULL) return null_error(); - callable = PyObject_GetAttr(callable, name); - if (callable == NULL) - return NULL; - - /* count the args */ - va_start(vargs, name); - args = objargs_mktuple(vargs); - va_end(vargs); - if (args == NULL) { - Py_DECREF(callable); + func = PyObject_GetAttr(callable, name); + if (func == NULL) { return NULL; } - tmp = PyObject_Call(callable, args, NULL); - Py_DECREF(args); - Py_DECREF(callable); - - return tmp; + + va_start(vargs, name); + stack = _PyStack_FromVa(small_stack, Py_ARRAY_LENGTH(small_stack), + vargs, &na); + va_end(vargs); + if (stack == NULL) { + return NULL; + } + + result = _PyObject_FastCall(func, stack, na, NULL); + Py_DECREF(func); + _PyStack_Free(stack, small_stack, na); + return result; } PyObject * _PyObject_CallMethodIdObjArgs(PyObject *callable, struct _Py_Identifier *name, ...) { - PyObject *args, *tmp; + PyObject *func; va_list vargs; + int na; + PyObject **stack; + PyObject *result; + PyObject* small_stack[_PyStack_SIZE]; if (callable == NULL || name == NULL) return null_error(); - callable = _PyObject_GetAttrId(callable, name); - if (callable == NULL) - return NULL; - - /* count the args */ - va_start(vargs, name); - args = objargs_mktuple(vargs); - va_end(vargs); - if (args == NULL) { - Py_DECREF(callable); + func = _PyObject_GetAttrId(callable, name); + if (func == NULL) { return NULL; } - tmp = PyObject_Call(callable, args, NULL); - Py_DECREF(args); - Py_DECREF(callable); - - return tmp; + + va_start(vargs, name); + stack = _PyStack_FromVa(small_stack, Py_ARRAY_LENGTH(small_stack), + vargs, &na); + va_end(vargs); + if (stack == NULL) { + return NULL; + } + + result = _PyObject_FastCall(func, stack, na, NULL); + Py_DECREF(func); + _PyStack_Free(stack, small_stack, na); + return result; } PyObject * PyObject_CallFunctionObjArgs(PyObject *callable, ...) { - PyObject *args, *tmp; va_list vargs; - - if (callable == NULL) + int na; + PyObject **stack; + PyObject *result; + PyObject* small_stack[_PyStack_SIZE]; + + if (callable == NULL) { return null_error(); - - /* count the args */ + } + va_start(vargs, callable); - args = objargs_mktuple(vargs); + stack = _PyStack_FromVa(small_stack, Py_ARRAY_LENGTH(small_stack), + vargs, &na); va_end(vargs); - if (args == NULL) + if (stack == NULL) { return NULL; - tmp = PyObject_Call(callable, args, NULL); - Py_DECREF(args); - - return tmp; + } + + result = _PyObject_FastCall(callable, stack, na, NULL); + _PyStack_Free(stack, small_stack, na); + return result; } diff -r 496e094f4734 -r 34456cce64bb Objects/bytesobject.c --- a/Objects/bytesobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/bytesobject.c Thu May 19 13:47:42 2016 +0200 @@ -548,7 +548,7 @@ format_obj(PyObject *v, const char **pbu /* does it support __bytes__? */ func = _PyObject_LookupSpecial(v, &PyId___bytes__); if (func != NULL) { - result = PyObject_CallFunctionObjArgs(func, NULL); + result = PyObject_CallNoArg(func); Py_DECREF(func); if (result == NULL) return NULL; diff -r 496e094f4734 -r 34456cce64bb Objects/classobject.c --- a/Objects/classobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/classobject.c Thu May 19 13:47:42 2016 +0200 @@ -301,34 +301,29 @@ method_traverse(PyMethodObject *im, visi return 0; } + static PyObject * -method_call(PyObject *func, PyObject *arg, PyObject *kw) +method_call(PyObject *func, PyObject **stack, int na, PyObject *kwargs) { + PyObject* small_stack[_PyStack_SIZE]; PyObject *self = PyMethod_GET_SELF(func); PyObject *result; + PyObject **stack2; func = PyMethod_GET_FUNCTION(func); if (self == NULL) { PyErr_BadInternalCall(); return NULL; } - else { - Py_ssize_t argcount = PyTuple_Size(arg); - PyObject *newarg = PyTuple_New(argcount + 1); - int i; - if (newarg == NULL) - return NULL; - Py_INCREF(self); - PyTuple_SET_ITEM(newarg, 0, self); - for (i = 0; i < argcount; i++) { - PyObject *v = PyTuple_GET_ITEM(arg, i); - Py_XINCREF(v); - PyTuple_SET_ITEM(newarg, i+1, v); - } - arg = newarg; + + stack2 = _PyStack_PrependArg(stack, na, small_stack, Py_ARRAY_LENGTH(small_stack), + self); + if (stack2 == NULL) { + return NULL; } - result = PyObject_Call((PyObject *)func, arg, kw); - Py_DECREF(arg); + + result = _PyObject_FastCall((PyObject *)func, stack2, 1 + na, kwargs); + _PyStack_Free(stack2, small_stack, 1 + na); return result; } @@ -361,17 +356,17 @@ PyTypeObject PyMethod_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)method_hash, /* tp_hash */ - method_call, /* tp_call */ + (ternaryfunc)method_call, /* tp_call */ 0, /* tp_str */ method_getattro, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTCALL, /* tp_flags */ method_doc, /* tp_doc */ (traverseproc)method_traverse, /* tp_traverse */ 0, /* tp_clear */ method_richcompare, /* tp_richcompare */ - offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ + offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ method_methods, /* tp_methods */ @@ -385,6 +380,7 @@ PyTypeObject PyMethod_Type = { 0, /* tp_init */ 0, /* tp_alloc */ method_new, /* tp_new */ + 0, /* tp_free */ }; /* Clear out the free list */ diff -r 496e094f4734 -r 34456cce64bb Objects/clinic/bytearrayobject.c.h --- a/Objects/clinic/bytearrayobject.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/clinic/bytearrayobject.c.h Thu May 19 13:47:42 2016 +0200 @@ -95,21 +95,23 @@ PyDoc_STRVAR(bytearray_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTEARRAY_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC, bytearray_maketrans__doc__}, + {"maketrans", (PyCFunction)bytearray_maketrans, METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, static PyObject * bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytearray_maketrans(void *null, PyObject *args) +bytearray_maketrans(void *null, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!PyArg_ParseStack(stack, nargs, "y*y*:maketrans", &frm, &to)) goto exit; + if (!_PyArg_NoKeywords("maketrans()", kwargs)) + goto exit; return_value = bytearray_maketrans_impl(&frm, &to); exit: @@ -137,23 +139,25 @@ PyDoc_STRVAR(bytearray_replace__doc__, "replaced."); #define BYTEARRAY_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, bytearray_replace__doc__}, + {"replace", (PyCFunction)bytearray_replace, METH_FASTCALL, bytearray_replace__doc__}, static PyObject * bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytearray_replace(PyByteArrayObject *self, PyObject *args) +bytearray_replace(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!PyArg_ParseStack(stack, nargs, "y*y*|n:replace", &old, &new, &count)) goto exit; + if (!_PyArg_NoKeywords("replace()", kwargs)) + goto exit; return_value = bytearray_replace_impl(self, &old, &new, count); exit: @@ -182,21 +186,21 @@ PyDoc_STRVAR(bytearray_split__doc__, " -1 (the default value) means no limit."); #define BYTEARRAY_SPLIT_METHODDEF \ - {"split", (PyCFunction)bytearray_split, METH_VARARGS|METH_KEYWORDS, bytearray_split__doc__}, + {"split", (PyCFunction)bytearray_split, METH_FASTCALL, bytearray_split__doc__}, static PyObject * bytearray_split_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit); static PyObject * -bytearray_split(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +bytearray_split(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sep", "maxsplit", NULL}; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:split", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|On:split", _keywords, &sep, &maxsplit)) goto exit; return_value = bytearray_split_impl(self, sep, maxsplit); @@ -254,21 +258,21 @@ PyDoc_STRVAR(bytearray_rsplit__doc__, "Splitting is done starting at the end of the bytearray and working to the front."); #define BYTEARRAY_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS|METH_KEYWORDS, bytearray_rsplit__doc__}, + {"rsplit", (PyCFunction)bytearray_rsplit, METH_FASTCALL, bytearray_rsplit__doc__}, static PyObject * bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit); static PyObject * -bytearray_rsplit(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +bytearray_rsplit(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sep", "maxsplit", NULL}; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:rsplit", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|On:rsplit", _keywords, &sep, &maxsplit)) goto exit; return_value = bytearray_rsplit_impl(self, sep, maxsplit); @@ -307,21 +311,23 @@ PyDoc_STRVAR(bytearray_insert__doc__, " The item to be inserted."); #define BYTEARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, bytearray_insert__doc__}, + {"insert", (PyCFunction)bytearray_insert, METH_FASTCALL, bytearray_insert__doc__}, static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); static PyObject * -bytearray_insert(PyByteArrayObject *self, PyObject *args) +bytearray_insert(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t index; int item; - if (!PyArg_ParseTuple(args, "nO&:insert", + if (!PyArg_ParseStack(stack, nargs, "nO&:insert", &index, _getbytevalue, &item)) goto exit; + if (!_PyArg_NoKeywords("insert()", kwargs)) + goto exit; return_value = bytearray_insert_impl(self, index, item); exit: @@ -382,20 +388,22 @@ PyDoc_STRVAR(bytearray_pop__doc__, "If no index argument is given, will pop the last item."); #define BYTEARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, bytearray_pop__doc__}, + {"pop", (PyCFunction)bytearray_pop, METH_FASTCALL, bytearray_pop__doc__}, static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); static PyObject * -bytearray_pop(PyByteArrayObject *self, PyObject *args) +bytearray_pop(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_ssize_t index = -1; - if (!PyArg_ParseTuple(args, "|n:pop", + if (!PyArg_ParseStack(stack, nargs, "|n:pop", &index)) goto exit; + if (!_PyArg_NoKeywords("pop()", kwargs)) + goto exit; return_value = bytearray_pop_impl(self, index); exit: @@ -440,21 +448,23 @@ PyDoc_STRVAR(bytearray_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTEARRAY_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytearray_strip, METH_VARARGS, bytearray_strip__doc__}, + {"strip", (PyCFunction)bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, static PyObject * bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * -bytearray_strip(PyByteArrayObject *self, PyObject *args) +bytearray_strip(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "strip", + if (!PyArg_UnpackStack(stack, nargs, "strip", 0, 1, &bytes)) goto exit; + if (!_PyArg_NoKeywords("strip", kwargs)) + goto exit; return_value = bytearray_strip_impl(self, bytes); exit: @@ -470,21 +480,23 @@ PyDoc_STRVAR(bytearray_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTEARRAY_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, bytearray_lstrip__doc__}, + {"lstrip", (PyCFunction)bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, static PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * -bytearray_lstrip(PyByteArrayObject *self, PyObject *args) +bytearray_lstrip(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "lstrip", + if (!PyArg_UnpackStack(stack, nargs, "lstrip", 0, 1, &bytes)) goto exit; + if (!_PyArg_NoKeywords("lstrip", kwargs)) + goto exit; return_value = bytearray_lstrip_impl(self, bytes); exit: @@ -500,21 +512,23 @@ PyDoc_STRVAR(bytearray_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTEARRAY_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, bytearray_rstrip__doc__}, + {"rstrip", (PyCFunction)bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, static PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * -bytearray_rstrip(PyByteArrayObject *self, PyObject *args) +bytearray_rstrip(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "rstrip", + if (!PyArg_UnpackStack(stack, nargs, "rstrip", 0, 1, &bytes)) goto exit; + if (!_PyArg_NoKeywords("rstrip", kwargs)) + goto exit; return_value = bytearray_rstrip_impl(self, bytes); exit: @@ -537,21 +551,21 @@ PyDoc_STRVAR(bytearray_decode__doc__, " can handle UnicodeDecodeErrors."); #define BYTEARRAY_DECODE_METHODDEF \ - {"decode", (PyCFunction)bytearray_decode, METH_VARARGS|METH_KEYWORDS, bytearray_decode__doc__}, + {"decode", (PyCFunction)bytearray_decode, METH_FASTCALL, bytearray_decode__doc__}, static PyObject * bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, const char *errors); static PyObject * -bytearray_decode(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +bytearray_decode(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"encoding", "errors", NULL}; const char *encoding = NULL; const char *errors = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:decode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|ss:decode", _keywords, &encoding, &errors)) goto exit; return_value = bytearray_decode_impl(self, encoding, errors); @@ -583,19 +597,19 @@ PyDoc_STRVAR(bytearray_splitlines__doc__ "true."); #define BYTEARRAY_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)bytearray_splitlines, METH_VARARGS|METH_KEYWORDS, bytearray_splitlines__doc__}, + {"splitlines", (PyCFunction)bytearray_splitlines, METH_FASTCALL, bytearray_splitlines__doc__}, static PyObject * bytearray_splitlines_impl(PyByteArrayObject *self, int keepends); static PyObject * -bytearray_splitlines(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +bytearray_splitlines(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"keepends", NULL}; int keepends = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:splitlines", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|i:splitlines", _keywords, &keepends)) goto exit; return_value = bytearray_splitlines_impl(self, keepends); @@ -658,20 +672,22 @@ PyDoc_STRVAR(bytearray_reduce_ex__doc__, "Return state information for pickling."); #define BYTEARRAY_REDUCE_EX_METHODDEF \ - {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_VARARGS, bytearray_reduce_ex__doc__}, + {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc__}, static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); static PyObject * -bytearray_reduce_ex(PyByteArrayObject *self, PyObject *args) +bytearray_reduce_ex(PyByteArrayObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int proto = 0; - if (!PyArg_ParseTuple(args, "|i:__reduce_ex__", + if (!PyArg_ParseStack(stack, nargs, "|i:__reduce_ex__", &proto)) goto exit; + if (!_PyArg_NoKeywords("__reduce_ex__()", kwargs)) + goto exit; return_value = bytearray_reduce_ex_impl(self, proto); exit: @@ -695,4 +711,4 @@ bytearray_sizeof(PyByteArrayObject *self { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=966c15ff22c5e243 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=46faff26ac647c51 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Objects/clinic/bytesobject.c.h --- a/Objects/clinic/bytesobject.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/clinic/bytesobject.c.h Thu May 19 13:47:42 2016 +0200 @@ -17,20 +17,20 @@ PyDoc_STRVAR(bytes_split__doc__, " -1 (the default value) means no limit."); #define BYTES_SPLIT_METHODDEF \ - {"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__}, + {"split", (PyCFunction)bytes_split, METH_FASTCALL, bytes_split__doc__}, static PyObject * bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); static PyObject * -bytes_split(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_split(PyBytesObject*self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sep", "maxsplit", NULL}; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:split", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|On:split", _keywords, &sep, &maxsplit)) goto exit; return_value = bytes_split_impl(self, sep, maxsplit); @@ -130,20 +130,20 @@ PyDoc_STRVAR(bytes_rsplit__doc__, "Splitting is done starting at the end of the bytes and working to the front."); #define BYTES_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__}, + {"rsplit", (PyCFunction)bytes_rsplit, METH_FASTCALL, bytes_rsplit__doc__}, static PyObject * bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); static PyObject * -bytes_rsplit(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_rsplit(PyBytesObject*self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sep", "maxsplit", NULL}; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:rsplit", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|On:rsplit", _keywords, &sep, &maxsplit)) goto exit; return_value = bytes_rsplit_impl(self, sep, maxsplit); @@ -176,21 +176,23 @@ PyDoc_STRVAR(bytes_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTES_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__}, + {"strip", (PyCFunction)bytes_strip, METH_FASTCALL, bytes_strip__doc__}, static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_strip(PyBytesObject *self, PyObject *args) +bytes_strip(PyBytesObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "strip", + if (!PyArg_UnpackStack(stack, nargs, "strip", 0, 1, &bytes)) goto exit; + if (!_PyArg_NoKeywords("strip", kwargs)) + goto exit; return_value = bytes_strip_impl(self, bytes); exit: @@ -206,21 +208,23 @@ PyDoc_STRVAR(bytes_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTES_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__}, + {"lstrip", (PyCFunction)bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__}, static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_lstrip(PyBytesObject *self, PyObject *args) +bytes_lstrip(PyBytesObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "lstrip", + if (!PyArg_UnpackStack(stack, nargs, "lstrip", 0, 1, &bytes)) goto exit; + if (!_PyArg_NoKeywords("lstrip", kwargs)) + goto exit; return_value = bytes_lstrip_impl(self, bytes); exit: @@ -236,21 +240,23 @@ PyDoc_STRVAR(bytes_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTES_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__}, + {"rstrip", (PyCFunction)bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__}, static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_rstrip(PyBytesObject *self, PyObject *args) +bytes_rstrip(PyBytesObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "rstrip", + if (!PyArg_UnpackStack(stack, nargs, "rstrip", 0, 1, &bytes)) goto exit; + if (!_PyArg_NoKeywords("rstrip", kwargs)) + goto exit; return_value = bytes_rstrip_impl(self, bytes); exit: @@ -314,21 +320,23 @@ PyDoc_STRVAR(bytes_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__}, + {"maketrans", (PyCFunction)bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytes_maketrans(void *null, PyObject *args) +bytes_maketrans(void *null, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!PyArg_ParseStack(stack, nargs, "y*y*:maketrans", &frm, &to)) goto exit; + if (!_PyArg_NoKeywords("maketrans()", kwargs)) + goto exit; return_value = bytes_maketrans_impl(&frm, &to); exit: @@ -356,23 +364,25 @@ PyDoc_STRVAR(bytes_replace__doc__, "replaced."); #define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, + {"replace", (PyCFunction)bytes_replace, METH_FASTCALL, bytes_replace__doc__}, static PyObject * bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytes_replace(PyBytesObject*self, PyObject *args) +bytes_replace(PyBytesObject*self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!PyArg_ParseStack(stack, nargs, "y*y*|n:replace", &old, &new, &count)) goto exit; + if (!_PyArg_NoKeywords("replace()", kwargs)) + goto exit; return_value = bytes_replace_impl(self, &old, &new, count); exit: @@ -402,21 +412,21 @@ PyDoc_STRVAR(bytes_decode__doc__, " can handle UnicodeDecodeErrors."); #define BYTES_DECODE_METHODDEF \ - {"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__}, + {"decode", (PyCFunction)bytes_decode, METH_FASTCALL, bytes_decode__doc__}, static PyObject * bytes_decode_impl(PyBytesObject*self, const char *encoding, const char *errors); static PyObject * -bytes_decode(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_decode(PyBytesObject*self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"encoding", "errors", NULL}; const char *encoding = NULL; const char *errors = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:decode", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|ss:decode", _keywords, &encoding, &errors)) goto exit; return_value = bytes_decode_impl(self, encoding, errors); @@ -435,19 +445,19 @@ PyDoc_STRVAR(bytes_splitlines__doc__, "true."); #define BYTES_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__}, + {"splitlines", (PyCFunction)bytes_splitlines, METH_FASTCALL, bytes_splitlines__doc__}, static PyObject * bytes_splitlines_impl(PyBytesObject*self, int keepends); static PyObject * -bytes_splitlines(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_splitlines(PyBytesObject*self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"keepends", NULL}; int keepends = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:splitlines", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "|i:splitlines", _keywords, &keepends)) goto exit; return_value = bytes_splitlines_impl(self, keepends); @@ -484,4 +494,4 @@ bytes_fromhex(PyTypeObject *type, PyObje exit: return return_value; } -/*[clinic end generated code: output=bd0ce8f25d7e18f4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8444c89d5d37c647 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Objects/clinic/dictobject.c.h --- a/Objects/clinic/dictobject.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/clinic/dictobject.c.h Thu May 19 13:47:42 2016 +0200 @@ -9,22 +9,24 @@ PyDoc_STRVAR(dict_fromkeys__doc__, "Returns a new dict with keys from iterable and values equal to value."); #define DICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS|METH_CLASS, dict_fromkeys__doc__}, + {"fromkeys", (PyCFunction)dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__}, static PyObject * dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value); static PyObject * -dict_fromkeys(PyTypeObject *type, PyObject *args) +dict_fromkeys(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *iterable; PyObject *value = Py_None; - if (!PyArg_UnpackTuple(args, "fromkeys", + if (!PyArg_UnpackStack(stack, nargs, "fromkeys", 1, 2, &iterable, &value)) goto exit; + if (!_PyArg_NoKeywords("fromkeys", kwargs)) + goto exit; return_value = dict_fromkeys_impl(type, iterable, value); exit: @@ -39,4 +41,4 @@ PyDoc_STRVAR(dict___contains____doc__, #define DICT___CONTAINS___METHODDEF \ {"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__}, -/*[clinic end generated code: output=fe74d676332fdba6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cc8658df01fadad1 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Objects/clinic/unicodeobject.c.h --- a/Objects/clinic/unicodeobject.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/clinic/unicodeobject.c.h Thu May 19 13:47:42 2016 +0200 @@ -17,25 +17,27 @@ PyDoc_STRVAR(unicode_maketrans__doc__, "must be a string, whose characters will be mapped to None in the result."); #define UNICODE_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__}, + {"maketrans", (PyCFunction)unicode_maketrans, METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, static PyObject * unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); static PyObject * -unicode_maketrans(void *null, PyObject *args) +unicode_maketrans(void *null, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *x; PyObject *y = NULL; PyObject *z = NULL; - if (!PyArg_ParseTuple(args, "O|UU:maketrans", + if (!PyArg_ParseStack(stack, nargs, "O|UU:maketrans", &x, &y, &z)) goto exit; + if (!_PyArg_NoKeywords("maketrans()", kwargs)) + goto exit; return_value = unicode_maketrans_impl(x, y, z); exit: return return_value; } -/*[clinic end generated code: output=94affdff5b2daff5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8e29b132879fc20b input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Objects/descrobject.c --- a/Objects/descrobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/descrobject.c Thu May 19 13:47:42 2016 +0200 @@ -210,14 +210,11 @@ getset_set(PyGetSetDescrObject *descr, P } static PyObject * -methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds) +methoddescr_call(PyMethodDescrObject *descr, PyObject **stack, int argc, PyObject *kwargs) { - Py_ssize_t argc; PyObject *self, *func, *result; /* Make sure that the first argument is acceptable as 'self' */ - assert(PyTuple_Check(args)); - argc = PyTuple_GET_SIZE(args); if (argc < 1) { PyErr_Format(PyExc_TypeError, "descriptor '%V' of '%.100s' " @@ -226,7 +223,8 @@ methoddescr_call(PyMethodDescrObject *de PyDescr_TYPE(descr)->tp_name); return NULL; } - self = PyTuple_GET_ITEM(args, 0); + self = stack[0]; + if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self), (PyObject *)PyDescr_TYPE(descr))) { PyErr_Format(PyExc_TypeError, @@ -242,13 +240,7 @@ methoddescr_call(PyMethodDescrObject *de func = PyCFunction_NewEx(descr->d_method, self, NULL); if (func == NULL) return NULL; - args = PyTuple_GetSlice(args, 1, argc); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObjectWithKeywords(func, args, kwds); - Py_DECREF(args); + result = _PyObject_FastCall(func, stack + 1, argc - 1, kwargs); Py_DECREF(func); return result; } @@ -259,6 +251,8 @@ classmethoddescr_call(PyMethodDescrObjec { Py_ssize_t argc; PyObject *self, *func, *result; + PyObject **stack; + int nargs2; /* Make sure that the first argument is acceptable as 'self' */ assert(PyTuple_Check(args)); @@ -271,6 +265,8 @@ classmethoddescr_call(PyMethodDescrObjec PyDescr_TYPE(descr)->tp_name); return NULL; } + assert(argc <= INT_MAX); + self = PyTuple_GET_ITEM(args, 0); if (!PyType_Check(self)) { PyErr_Format(PyExc_TypeError, @@ -295,26 +291,19 @@ classmethoddescr_call(PyMethodDescrObjec func = PyCFunction_NewEx(descr->d_method, self, NULL); if (func == NULL) return NULL; - args = PyTuple_GetSlice(args, 1, argc); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObjectWithKeywords(func, args, kwds); + + stack = _PyStack_FromBorrowedTuple(args, 1, &nargs2); + result = _PyObject_FastCall(func, stack, nargs2, kwds); Py_DECREF(func); - Py_DECREF(args); return result; } static PyObject * -wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds) +wrapperdescr_call(PyWrapperDescrObject *descr, PyObject **stack, int argc, PyObject *kwargs) { - Py_ssize_t argc; PyObject *self, *func, *result; /* Make sure that the first argument is acceptable as 'self' */ - assert(PyTuple_Check(args)); - argc = PyTuple_GET_SIZE(args); if (argc < 1) { PyErr_Format(PyExc_TypeError, "descriptor '%V' of '%.100s' " @@ -323,7 +312,8 @@ wrapperdescr_call(PyWrapperDescrObject * PyDescr_TYPE(descr)->tp_name); return NULL; } - self = PyTuple_GET_ITEM(args, 0); + self = stack[0]; + if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self), (PyObject *)PyDescr_TYPE(descr))) { PyErr_Format(PyExc_TypeError, @@ -336,16 +326,13 @@ wrapperdescr_call(PyWrapperDescrObject * return NULL; } + func = PyWrapper_New((PyObject *)descr, self); - if (func == NULL) - return NULL; - args = PyTuple_GetSlice(args, 1, argc); - if (args == NULL) { - Py_DECREF(func); + if (func == NULL) { return NULL; } - result = PyEval_CallObjectWithKeywords(func, args, kwds); - Py_DECREF(args); + + result = _PyObject_FastCall(func, stack + 1, argc - 1, kwargs); Py_DECREF(func); return result; } @@ -510,7 +497,7 @@ PyTypeObject PyMethodDescr_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTCALL, /* tp_flags */ 0, /* tp_doc */ descr_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -524,7 +511,6 @@ PyTypeObject PyMethodDescr_Type = { 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc)method_get, /* tp_descr_get */ - 0, /* tp_descr_set */ }; /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ @@ -659,7 +645,7 @@ PyTypeObject PyWrapperDescr_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTCALL, /* tp_flags */ 0, /* tp_doc */ descr_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -673,7 +659,6 @@ PyTypeObject PyWrapperDescr_Type = { 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc)wrapperdescr_get, /* tp_descr_get */ - 0, /* tp_descr_set */ }; static PyDescrObject * @@ -759,6 +744,21 @@ PyDescr_NewWrapper(PyTypeObject *type, s return (PyObject *)descr; } +PyObject * +_PyDescr_NewWrapperEx(PyTypeObject *type, struct wrapperbase *base, void *wrapped, int type_flags) +{ + PyWrapperDescrObject *descr; + + descr = (PyWrapperDescrObject *)descr_new(&PyWrapperDescr_Type, + type, base->name); + if (descr != NULL) { + descr->d_base = base; + descr->d_wrapped = wrapped; + descr->d_type_flags = type_flags; + } + return (PyObject *)descr; +} + /* --- mappingproxy: read-only proxy for mappings --- */ @@ -1176,14 +1176,30 @@ static PyGetSetDef wrapper_getsets[] = { }; static PyObject * -wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds) +wrapper_call(wrapperobject *wp, PyObject **stack, int nargs, PyObject *kwds) { - wrapperfunc wrapper = wp->descr->d_base->wrapper; + struct wrapperbase *d_base = wp->descr->d_base; + fastwrapperfunc fastwrapper; PyObject *self = wp->self; + if (wp->descr->d_base->flags & PyWrapperFlag_FASTWRAPPER) { + wrapperfunc_fast wrapperfast = (wrapperfunc_fast)d_base->wrapper; + + return (*wrapperfast)(self, wp->descr->d_wrapped, wp->descr->d_type_flags, stack, nargs, kwds); + } + if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) { - wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper; - return (*wk)(self, args, wp->descr->d_wrapped, kwds); + wrapperfunc_kwds wrapperkw = (wrapperfunc_kwds)d_base->wrapper; + PyObject *args, *result; + + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + return NULL; + } + + result = (*wrapperkw)(self, args, wp->descr->d_wrapped, kwds); + Py_DECREF(args); + return result; } if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_Size(kwds) != 0)) { @@ -1192,7 +1208,23 @@ wrapper_call(wrapperobject *wp, PyObject wp->descr->d_base->name); return NULL; } - return (*wrapper)(self, args, wp->descr->d_wrapped); + + fastwrapper = d_base->fastwrapper; + if (!fastwrapper) { + wrapperfunc wrapper = d_base->wrapper; + PyObject *args, *result; + + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + return NULL; + } + + result = (*wrapper)(self, args, wp->descr->d_wrapped); + Py_DECREF(args); + return result; + } + + return (*fastwrapper)(self, stack, nargs, wp->descr->d_wrapped); } static int @@ -1225,7 +1257,7 @@ PyTypeObject _PyMethodWrapper_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTCALL, /* tp_flags */ 0, /* tp_doc */ wrapper_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -1236,10 +1268,6 @@ PyTypeObject _PyMethodWrapper_Type = { wrapper_methods, /* tp_methods */ wrapper_members, /* tp_members */ wrapper_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ }; PyObject * @@ -1372,9 +1400,6 @@ property_dealloc(PyObject *self) static PyObject * property_descr_get(PyObject *self, PyObject *obj, PyObject *type) { - static PyObject * volatile cached_args = NULL; - PyObject *args; - PyObject *ret; propertyobject *gs = (propertyobject *)self; if (obj == NULL || obj == Py_None) { @@ -1385,29 +1410,8 @@ property_descr_get(PyObject *self, PyObj PyErr_SetString(PyExc_AttributeError, "unreadable attribute"); return NULL; } - args = cached_args; - if (!args || Py_REFCNT(args) != 1) { - Py_CLEAR(cached_args); - if (!(cached_args = args = PyTuple_New(1))) - return NULL; - } - Py_INCREF(args); - assert (Py_REFCNT(args) == 2); - Py_INCREF(obj); - PyTuple_SET_ITEM(args, 0, obj); - ret = PyObject_Call(gs->prop_get, args, NULL); - if (args == cached_args) { - if (Py_REFCNT(args) == 2) { - obj = PyTuple_GET_ITEM(args, 0); - PyTuple_SET_ITEM(args, 0, NULL); - Py_XDECREF(obj); - } - else { - Py_CLEAR(cached_args); - } - } - Py_DECREF(args); - return ret; + + return PyObject_CallArg1(gs->prop_get, obj); } static int @@ -1428,7 +1432,7 @@ property_descr_set(PyObject *self, PyObj return -1; } if (value == NULL) - res = PyObject_CallFunctionObjArgs(func, obj, NULL); + res = PyObject_CallArg1(func, obj); else res = PyObject_CallFunctionObjArgs(func, obj, value, NULL); if (res == NULL) @@ -1467,7 +1471,7 @@ property_copy(PyObject *old, PyObject *g doc = pold->prop_doc ? pold->prop_doc : Py_None; } - new = PyObject_CallFunction(type, "OOOO", get, set, del, doc); + new = PyObject_CallFunctionObjArgs(type, get, set, del, doc, NULL); Py_DECREF(type); if (new == NULL) return NULL; @@ -1475,13 +1479,13 @@ property_copy(PyObject *old, PyObject *g } static int -property_init(PyObject *self, PyObject *args, PyObject *kwds) +property_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL; static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; propertyobject *prop = (propertyobject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property", + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|OOOO:property", kwlist, &get, &set, &del, &doc)) return -1; @@ -1637,8 +1641,8 @@ PyTypeObject PyProperty_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, /* tp_flags */ property_doc, /* tp_doc */ property_traverse, /* tp_traverse */ (inquiry)property_clear, /* tp_clear */ @@ -1654,8 +1658,8 @@ PyTypeObject PyProperty_Type = { property_descr_get, /* tp_descr_get */ property_descr_set, /* tp_descr_set */ 0, /* tp_dictoffset */ - property_init, /* tp_init */ + (initproc)property_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ + (newfunc)_PyType_FastGenericNew, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/dictobject.c --- a/Objects/dictobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/dictobject.c Thu May 19 13:47:42 2016 +0200 @@ -1502,7 +1502,7 @@ PyObject * PyObject *d; int status; - d = PyObject_CallObject(cls, NULL); + d = PyObject_CallNoArg(cls); if (d == NULL) return NULL; @@ -1923,12 +1923,12 @@ dict_fromkeys_impl(PyTypeObject *type, P } static int -dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, const char *methname) +dict_update_common_stack(PyObject *self, PyObject **stack, int nargs, PyObject *kwds, const char *methname) { PyObject *arg = NULL; int result = 0; - if (!PyArg_UnpackTuple(args, methname, 0, 1, &arg)) + if (!PyArg_UnpackStack(stack, nargs, methname, 0, 1, &arg)) result = -1; else if (arg != NULL) { @@ -1948,9 +1948,9 @@ dict_update_common(PyObject *self, PyObj } static PyObject * -dict_update(PyObject *self, PyObject *args, PyObject *kwds) +dict_update(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { - if (dict_update_common(self, args, kwds, "update") != -1) + if (dict_update_common_stack(self, stack, nargs, kwds, "update") != -1) Py_RETURN_NONE; return NULL; } @@ -2646,7 +2646,7 @@ static PyMethodDef mapp_methods[] = { items__doc__}, {"values", (PyCFunction)dictvalues_new, METH_NOARGS, values__doc__}, - {"update", (PyCFunction)dict_update, METH_VARARGS | METH_KEYWORDS, + {"update", (PyCFunction)dict_update, METH_FASTCALL, update__doc__}, DICT_FROMKEYS_METHODDEF {"clear", (PyCFunction)dict_clear, METH_NOARGS, @@ -2702,7 +2702,7 @@ static PySequenceMethods dict_as_sequenc }; static PyObject * -dict_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +dict_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *self; PyDictObject *d; @@ -2727,9 +2727,9 @@ dict_new(PyTypeObject *type, PyObject *a } static int -dict_init(PyObject *self, PyObject *args, PyObject *kwds) +dict_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { - return dict_update_common(self, args, kwds, "dict"); + return dict_update_common_stack(self, stack, nargs, kwds, "dict"); } static PyObject * @@ -2769,8 +2769,8 @@ PyTypeObject PyDict_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DICT_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_DICT_SUBCLASS | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, /* tp_flags */ dictionary_doc, /* tp_doc */ dict_traverse, /* tp_traverse */ dict_tp_clear, /* tp_clear */ @@ -2786,9 +2786,9 @@ PyTypeObject PyDict_Type = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - dict_init, /* tp_init */ + (initproc)dict_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - dict_new, /* tp_new */ + (newfunc)dict_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/enumobject.c --- a/Objects/enumobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/enumobject.c Thu May 19 13:47:42 2016 +0200 @@ -11,14 +11,14 @@ typedef struct { } enumobject; static PyObject * -enum_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +enum_new(PyTypeObject *type, PyObject **stack ,int nargs, PyObject *kwds) { enumobject *en; PyObject *seq = NULL; PyObject *start = NULL; static char *kwlist[] = {"iterable", "start", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:enumerate", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "O|O:enumerate", kwlist, &seq, &start)) return NULL; @@ -205,7 +205,7 @@ PyTypeObject PyEnum_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_FASTNEW, /* tp_flags */ enum_doc, /* tp_doc */ (traverseproc)enum_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -223,7 +223,7 @@ PyTypeObject PyEnum_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - enum_new, /* tp_new */ + (newfunc)enum_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/exceptions.c --- a/Objects/exceptions.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/exceptions.c Thu May 19 13:47:42 2016 +0200 @@ -29,30 +29,31 @@ static PyObject *errnomap = NULL; * BaseException */ static PyObject * -BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +BaseException_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyBaseExceptionObject *self; + PyObject *args; + + if (nargs) { + args = _PyStack_AsTuple(stack, nargs); + } + else { + args = PyTuple_New(0); + } + if (args == NULL) { + return NULL; + } self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); - if (!self) + if (!self) { + Py_DECREF(args); return NULL; + } /* the dict is created on the fly in PyObject_GenericSetAttr */ self->dict = NULL; self->traceback = self->cause = self->context = NULL; self->suppress_context = 0; - - if (args) { - self->args = args; - Py_INCREF(args); - return (PyObject *)self; - } - - self->args = PyTuple_New(0); - if (!self->args) { - Py_DECREF(self); - return NULL; - } - + self->args = args; return (PyObject *)self; } @@ -69,6 +70,24 @@ BaseException_init(PyBaseExceptionObject } static int +BaseException_fastinit(PyBaseExceptionObject *self, PyObject **stack, int nargs, PyObject *kwds) +{ + PyObject *args; + + if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) + return -1; + + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + return -1; + } + + Py_XSETREF(self->args, args); + + return 0; +} + +static int BaseException_clear(PyBaseExceptionObject *self) { Py_CLEAR(self->dict); @@ -373,7 +392,7 @@ static PyTypeObject _PyExc_BaseException PyObject_GenericSetAttr, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASE_EXC_SUBCLASS, /*tp_flags*/ + Py_TPFLAGS_BASE_EXC_SUBCLASS | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, /*tp_flags*/ PyDoc_STR("Common base class for all exceptions"), /* tp_doc */ (traverseproc)BaseException_traverse, /* tp_traverse */ (inquiry)BaseException_clear, /* tp_clear */ @@ -389,9 +408,9 @@ static PyTypeObject _PyExc_BaseException 0, /* tp_descr_get */ 0, /* tp_descr_set */ offsetof(PyBaseExceptionObject, dict), /* tp_dictoffset */ - (initproc)BaseException_init, /* tp_init */ + (initproc)BaseException_fastinit, /* tp_init */ 0, /* tp_alloc */ - BaseException_new, /* tp_new */ + (newfunc)BaseException_new, /* tp_new */ }; /* the CPython API expects exceptions to be (PyObject *) - both a hold-over from the previous implmentation and also allowing Python objects to be used @@ -408,11 +427,12 @@ static PyTypeObject _PyExc_ ## EXCNAME = sizeof(PyBaseExceptionObject), \ 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, \ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, \ PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(PyBaseExceptionObject, dict), \ - (initproc)BaseException_init, 0, BaseException_new,\ + (initproc)BaseException_fastinit, 0, \ + (newfunc)BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME @@ -1893,11 +1913,11 @@ static PyTypeObject _PyExc_UnicodeEncode sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTNEW, PyDoc_STR("Unicode encoding error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeEncodeError_init, 0, BaseException_new, + (initproc)UnicodeEncodeError_init, 0, (newfunc)BaseException_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; @@ -2012,11 +2032,11 @@ static PyTypeObject _PyExc_UnicodeDecode sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTNEW, PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeDecodeError_init, 0, BaseException_new, + (initproc)UnicodeDecodeError_init, 0, (newfunc)BaseException_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; @@ -2111,11 +2131,11 @@ static PyTypeObject _PyExc_UnicodeTransl sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTNEW, PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeTranslateError_init, 0, BaseException_new, + (initproc)UnicodeTranslateError_init, 0, (newfunc)BaseException_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; @@ -2199,20 +2219,23 @@ static PyBaseExceptionObject *memerrors_ static int memerrors_numfree = 0; static PyObject * -MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +MemoryError_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyBaseExceptionObject *self; if (type != (PyTypeObject *) PyExc_MemoryError) - return BaseException_new(type, args, kwds); + return BaseException_new(type, stack, nargs, kwds); + if (memerrors_freelist == NULL) - return BaseException_new(type, args, kwds); + return BaseException_new(type, stack, nargs, kwds); + /* Fetch object from freelist and revive it */ self = memerrors_freelist; self->args = PyTuple_New(0); /* This shouldn't happen since the empty tuple is persistent */ if (self->args == NULL) return NULL; + memerrors_freelist = (PyBaseExceptionObject *) self->dict; memerrors_numfree--; self->dict = NULL; @@ -2244,7 +2267,7 @@ preallocate_memerrors(void) PyObject *errors[MEMERRORS_SAVE]; for (i = 0; i < MEMERRORS_SAVE; i++) { errors[i] = MemoryError_new((PyTypeObject *) PyExc_MemoryError, - NULL, NULL); + NULL, 0, NULL); if (!errors[i]) Py_FatalError("Could not preallocate MemoryError object"); } @@ -2270,11 +2293,11 @@ static PyTypeObject _PyExc_MemoryError = sizeof(PyBaseExceptionObject), 0, (destructor)MemoryError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTNEW, PyDoc_STR("Out of memory."), (traverseproc)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, offsetof(PyBaseExceptionObject, dict), - (initproc)BaseException_init, 0, MemoryError_new + (initproc)BaseException_init, 0, (newfunc)MemoryError_new }; PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError; @@ -2634,7 +2657,7 @@ void preallocate_memerrors(); if (!PyExc_RecursionErrorInst) { - PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RecursionError, NULL, NULL); + PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RecursionError, NULL, 0, NULL); if (!PyExc_RecursionErrorInst) Py_FatalError("Cannot pre-allocate RecursionError instance for " "recursion errors"); @@ -2722,7 +2745,7 @@ PyObject * ) ); if (caught_type->tp_init != (initproc)BaseException_init || - caught_type->tp_new != BaseException_new || + caught_type->tp_new != (newfunc)BaseException_new || !same_basic_size || caught_type->tp_itemsize != _PyExc_BaseException.tp_itemsize) { /* We can't be sure we can wrap this safely, since it may contain diff -r 496e094f4734 -r 34456cce64bb Objects/fileobject.c --- a/Objects/fileobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/fileobject.c Thu May 19 13:47:42 2016 +0200 @@ -58,23 +58,19 @@ PyFile_GetLine(PyObject *f, int n) { PyObject *reader; - PyObject *args; _Py_IDENTIFIER(readline); reader = _PyObject_GetAttrId(f, &PyId_readline); if (reader == NULL) return NULL; - if (n <= 0) - args = PyTuple_New(0); - else - args = Py_BuildValue("(i)", n); - if (args == NULL) { - Py_DECREF(reader); - return NULL; + + if (n > 0) { + result = PyObject_CallFunction(reader, "i", n); } - result = PyEval_CallObject(reader, args); + else { + result = PyObject_CallNoArg(reader); + } Py_DECREF(reader); - Py_DECREF(args); if (result != NULL && !PyBytes_Check(result) && !PyUnicode_Check(result)) { Py_DECREF(result); @@ -127,7 +123,7 @@ PyFile_GetLine(PyObject *f, int n) int PyFile_WriteObject(PyObject *v, PyObject *f, int flags) { - PyObject *writer, *value, *args, *result; + PyObject *writer, *value, *result; _Py_IDENTIFIER(write); if (f == NULL) { @@ -146,14 +142,7 @@ PyFile_WriteObject(PyObject *v, PyObject Py_DECREF(writer); return -1; } - args = PyTuple_Pack(1, value); - if (args == NULL) { - Py_DECREF(value); - Py_DECREF(writer); - return -1; - } - result = PyEval_CallObject(writer, args); - Py_DECREF(args); + result = PyObject_CallArg1(writer, value); Py_DECREF(value); Py_DECREF(writer); if (result == NULL) @@ -204,7 +193,7 @@ PyObject_AsFileDescriptor(PyObject *o) } else if ((meth = _PyObject_GetAttrId(o, &PyId_fileno)) != NULL) { - PyObject *fno = PyEval_CallObject(meth, NULL); + PyObject *fno = PyObject_CallNoArg(meth); Py_DECREF(meth); if (fno == NULL) return -1; diff -r 496e094f4734 -r 34456cce64bb Objects/floatobject.c --- a/Objects/floatobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/floatobject.c Thu May 19 13:47:42 2016 +0200 @@ -1195,7 +1195,6 @@ Return a hexadecimal representation of a static PyObject * float_fromhex(PyObject *cls, PyObject *arg) { - PyObject *result_as_float, *result; double x; long exp, top_exp, lsb, key_digit; char *s, *coeff_start, *s_store, *coeff_end, *exp_start, *s_end; @@ -1410,12 +1409,7 @@ float_fromhex(PyObject *cls, PyObject *a s++; if (s != s_end) goto parse_error; - result_as_float = Py_BuildValue("(d)", negate ? -x : x); - if (result_as_float == NULL) - return NULL; - result = PyObject_CallObject(cls, result_as_float); - Py_DECREF(result_as_float); - return result; + return PyObject_CallFunction(cls, "d", negate ? -x : x); overflow_error: PyErr_SetString(PyExc_OverflowError, @@ -1531,17 +1525,17 @@ PyDoc_STRVAR(float_as_integer_ratio_doc, static PyObject * -float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +float_subtype_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds); static PyObject * -float_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +float_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *x = Py_False; /* Integer zero */ static char *kwlist[] = {"x", 0}; if (type != &PyFloat_Type) - return float_subtype_new(type, args, kwds); /* Wimp out */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x)) + return float_subtype_new(type, stack, nargs, kwds); /* Wimp out */ + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|O:float", kwlist, &x)) return NULL; /* If it's a string, but not a string subclass, use PyFloat_FromString. */ @@ -1556,12 +1550,12 @@ float_new(PyTypeObject *type, PyObject * from the regular float. The regular float is then thrown away. */ static PyObject * -float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +float_subtype_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *tmp, *newobj; assert(PyType_IsSubtype(type, &PyFloat_Type)); - tmp = float_new(&PyFloat_Type, args, kwds); + tmp = float_new(&PyFloat_Type, stack, nargs, kwds); if (tmp == NULL) return NULL; assert(PyFloat_Check(tmp)); @@ -1852,7 +1846,8 @@ PyTypeObject PyFloat_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_FASTNEW, /* tp_flags */ float_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -1870,7 +1865,7 @@ PyTypeObject PyFloat_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - float_new, /* tp_new */ + (newfunc)float_new, /* tp_new */ }; int diff -r 496e094f4734 -r 34456cce64bb Objects/funcobject.c --- a/Objects/funcobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/funcobject.c Thu May 19 13:47:42 2016 +0200 @@ -563,55 +563,9 @@ func_traverse(PyFunctionObject *f, visit } static PyObject * -function_call(PyObject *func, PyObject *arg, PyObject *kw) +function_call(PyObject *func, PyObject **stack, int na, PyObject *kwargs) { - PyObject *result; - PyObject *argdefs; - PyObject *kwtuple = NULL; - PyObject **d, **k; - Py_ssize_t nk, nd; - - argdefs = PyFunction_GET_DEFAULTS(func); - if (argdefs != NULL && PyTuple_Check(argdefs)) { - d = &PyTuple_GET_ITEM((PyTupleObject *)argdefs, 0); - nd = PyTuple_GET_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } - - if (kw != NULL && PyDict_Check(kw)) { - Py_ssize_t pos, i; - nk = PyDict_Size(kw); - kwtuple = PyTuple_New(2*nk); - if (kwtuple == NULL) - return NULL; - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kw, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i/2; - } - else { - k = NULL; - nk = 0; - } - - result = PyEval_EvalCodeEx( - PyFunction_GET_CODE(func), - PyFunction_GET_GLOBALS(func), (PyObject *)NULL, - &PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg), - k, nk, d, nd, - PyFunction_GET_KW_DEFAULTS(func), - PyFunction_GET_CLOSURE(func)); - - Py_XDECREF(kwtuple); - - return result; + return _PyFunction_FastCall(func, stack, na, kwargs); } /* Bind a function to an object */ @@ -640,12 +594,13 @@ PyTypeObject PyFunction_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - function_call, /* tp_call */ + (ternaryfunc)function_call, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC + | Py_TPFLAGS_FASTCALL, /* tp_flags */ func_doc, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -734,12 +689,12 @@ cm_descr_get(PyObject *self, PyObject *o } static int -cm_init(PyObject *self, PyObject *args, PyObject *kwds) +cm_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { classmethod *cm = (classmethod *)self; PyObject *callable; - if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable)) + if (!PyArg_UnpackStack(stack, nargs, "classmethod", 1, 1, &callable)) return -1; if (!_PyArg_NoKeywords("classmethod", kwds)) return -1; @@ -816,7 +771,8 @@ PyTypeObject PyClassMethod_Type = { 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, /* tp_flags */ classmethod_doc, /* tp_doc */ (traverseproc)cm_traverse, /* tp_traverse */ (inquiry)cm_clear, /* tp_clear */ @@ -832,9 +788,9 @@ PyTypeObject PyClassMethod_Type = { cm_descr_get, /* tp_descr_get */ 0, /* tp_descr_set */ offsetof(classmethod, cm_dict), /* tp_dictoffset */ - cm_init, /* tp_init */ + (initproc)cm_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ + (newfunc)_PyType_FastGenericNew, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -913,12 +869,12 @@ sm_descr_get(PyObject *self, PyObject *o } static int -sm_init(PyObject *self, PyObject *args, PyObject *kwds) +sm_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { staticmethod *sm = (staticmethod *)self; PyObject *callable; - if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable)) + if (!PyArg_UnpackStack(stack, nargs, "staticmethod", 1, 1, &callable)) return -1; if (!_PyArg_NoKeywords("staticmethod", kwds)) return -1; @@ -992,7 +948,8 @@ PyTypeObject PyStaticMethod_Type = { 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC \ + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, /* tp_flags */ staticmethod_doc, /* tp_doc */ (traverseproc)sm_traverse, /* tp_traverse */ (inquiry)sm_clear, /* tp_clear */ @@ -1008,9 +965,9 @@ PyTypeObject PyStaticMethod_Type = { sm_descr_get, /* tp_descr_get */ 0, /* tp_descr_set */ offsetof(staticmethod, sm_dict), /* tp_dictoffset */ - sm_init, /* tp_init */ + (initproc)sm_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ + (newfunc)_PyType_FastGenericNew, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/genobject.c --- a/Objects/genobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/genobject.c Thu May 19 13:47:42 2016 +0200 @@ -364,7 +364,7 @@ gen_throw(PyGenObject *gen, PyObject *ar goto throw_here; } gen->gi_running = 1; - ret = PyObject_CallObject(meth, args); + ret = PyObject_Call(meth, args, NULL); gen->gi_running = 0; Py_DECREF(meth); } diff -r 496e094f4734 -r 34456cce64bb Objects/iterobject.c --- a/Objects/iterobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/iterobject.c Thu May 19 13:47:42 2016 +0200 @@ -209,12 +209,8 @@ static PyObject * calliter_iternext(calliterobject *it) { if (it->it_callable != NULL) { - PyObject *args = PyTuple_New(0); PyObject *result; - if (args == NULL) - return NULL; - result = PyObject_Call(it->it_callable, args, NULL); - Py_DECREF(args); + result = PyObject_CallNoArg(it->it_callable); if (result != NULL) { int ok; ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ); diff -r 496e094f4734 -r 34456cce64bb Objects/listobject.c --- a/Objects/listobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/listobject.c Thu May 19 13:47:42 2016 +0200 @@ -903,13 +903,13 @@ list_inplace_concat(PyListObject *self, } static PyObject * -listpop(PyListObject *self, PyObject *args) +listpop(PyListObject *self, PyObject **stack, int nargs) { Py_ssize_t i = -1; PyObject *v; int status; - if (!PyArg_ParseTuple(args, "|n:pop", &i)) + if (!PyArg_ParseStack(stack, nargs, "|n:pop", &i)) return NULL; if (Py_SIZE(self) == 0) { @@ -1962,8 +1962,7 @@ listsort(PyListObject *self, PyObject *a } for (i = 0; i < saved_ob_size ; i++) { - keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i], - NULL); + keys[i] = PyObject_CallArg1(keyfunc, saved_ob_item[i]); if (keys[i] == NULL) { for (i=i-1 ; i>=0 ; i--) Py_DECREF(keys[i]); @@ -2286,12 +2285,12 @@ list_richcompare(PyObject *v, PyObject * } static int -list_init(PyListObject *self, PyObject *args, PyObject *kw) +list_init(PyListObject *self, PyObject **stack, int nargs, PyObject *kw) { + static char *kwlist[] = {"sequence", 0}; PyObject *arg = NULL; - static char *kwlist[] = {"sequence", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:list", kwlist, &arg)) + if (!PyArg_ParseStackAndKeywords(stack, nargs, kw, "|O:list", kwlist, &arg)) return -1; /* Verify list invariants established by PyType_GenericAlloc() */ @@ -2368,7 +2367,7 @@ static PyMethodDef list_methods[] = { {"append", (PyCFunction)listappend, METH_O, append_doc}, {"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc}, {"extend", (PyCFunction)listextend, METH_O, extend_doc}, - {"pop", (PyCFunction)listpop, METH_VARARGS, pop_doc}, + {"pop", (PyCFunction)listpop, METH_FASTCALL, pop_doc}, {"remove", (PyCFunction)listremove, METH_O, remove_doc}, {"index", (PyCFunction)listindex, METH_VARARGS, index_doc}, {"count", (PyCFunction)listcount, METH_O, count_doc}, @@ -2637,8 +2636,9 @@ PyTypeObject PyList_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC + | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS + | Py_TPFLAGS_FASTINIT, /* tp_flags */ list_doc, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ (inquiry)list_clear, /* tp_clear */ diff -r 496e094f4734 -r 34456cce64bb Objects/longobject.c --- a/Objects/longobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/longobject.c Thu May 19 13:47:42 2016 +0200 @@ -4695,18 +4695,18 @@ long_float(PyObject *v) } static PyObject * -long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +long_subtype_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds); static PyObject * -long_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +long_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *obase = NULL, *x = NULL; Py_ssize_t base; static char *kwlist[] = {"x", "base", 0}; if (type != &PyLong_Type) - return long_subtype_new(type, args, kwds); /* Wimp out */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:int", kwlist, + return long_subtype_new(type, stack, nargs, kwds); /* Wimp out */ + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|OO:int", kwlist, &x, &obase)) return NULL; if (x == NULL) { @@ -4746,19 +4746,14 @@ long_new(PyTypeObject *type, PyObject *a } } -/* Wimpy, slow approach to tp_new calls for subtypes of int: - first create a regular int from whatever arguments we got, - then allocate a subtype instance and initialize it from - the regular int. The regular int is then thrown away. -*/ static PyObject * -long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +long_subtype_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyLongObject *tmp, *newobj; Py_ssize_t i, n; assert(PyType_IsSubtype(type, &PyLong_Type)); - tmp = (PyLongObject *)long_new(&PyLong_Type, args, kwds); + tmp = (PyLongObject *)long_new(&PyLong_Type, stack, nargs, kwds); if (tmp == NULL) return NULL; assert(PyLong_Check(tmp)); @@ -5064,7 +5059,7 @@ long_is_finite(PyObject *v) static PyObject * -long_to_bytes(PyLongObject *v, PyObject *args, PyObject *kwds) +long_to_bytes(PyLongObject *v, PyObject **stack, int nargs, PyObject *kwds) { PyObject *byteorder_str; PyObject *is_signed_obj = NULL; @@ -5074,12 +5069,13 @@ long_to_bytes(PyLongObject *v, PyObject PyObject *bytes; static char *kwlist[] = {"length", "byteorder", "signed", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "nU|O:to_bytes", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "nU|O:to_bytes", kwlist, &length, &byteorder_str, &is_signed_obj)) return NULL; - if (args != NULL && Py_SIZE(args) > 2) { + /* FIXME: use "$" format? */ + if (nargs > 2) { PyErr_SetString(PyExc_TypeError, "'signed' is a keyword-only argument"); return NULL; @@ -5146,7 +5142,7 @@ used to represent the integer. If signe is given, an OverflowError is raised."); static PyObject * -long_from_bytes(PyTypeObject *type, PyObject *args, PyObject *kwds) +long_from_bytes(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *byteorder_str; PyObject *is_signed_obj = NULL; @@ -5157,12 +5153,12 @@ long_from_bytes(PyTypeObject *type, PyOb PyObject *long_obj; static char *kwlist[] = {"bytes", "byteorder", "signed", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OU|O:from_bytes", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "OU|O:from_bytes", kwlist, &obj, &byteorder_str, &is_signed_obj)) return NULL; - if (args != NULL && Py_SIZE(args) > 2) { + if (nargs > 2) { PyErr_SetString(PyExc_TypeError, "'signed' is a keyword-only argument"); return NULL; @@ -5251,9 +5247,9 @@ static PyMethodDef long_methods[] = { "Returns always True."}, #endif {"to_bytes", (PyCFunction)long_to_bytes, - METH_VARARGS|METH_KEYWORDS, long_to_bytes_doc}, + METH_FASTCALL, long_to_bytes_doc}, {"from_bytes", (PyCFunction)long_from_bytes, - METH_VARARGS|METH_KEYWORDS|METH_CLASS, long_from_bytes_doc}, + METH_FASTCALL|METH_CLASS, long_from_bytes_doc}, {"__trunc__", (PyCFunction)long_long, METH_NOARGS, "Truncating an Integral returns itself."}, {"__floor__", (PyCFunction)long_long, METH_NOARGS, @@ -5363,8 +5359,8 @@ PyTypeObject PyLong_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_LONG_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LONG_SUBCLASS + | Py_TPFLAGS_FASTNEW, /* tp_flags */ long_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -5382,7 +5378,7 @@ PyTypeObject PyLong_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - long_new, /* tp_new */ + (newfunc)long_new, /* tp_new */ PyObject_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/methodobject.c --- a/Objects/methodobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/methodobject.c Thu May 19 13:47:42 2016 +0200 @@ -77,6 +77,26 @@ PyCFunction_GetFlags(PyObject *op) return PyCFunction_GET_FLAGS(op); } +static PyObject * +PyCFunction_FastCall_FromArgs(PyObject *func, PyObject *args, PyObject *kwargs) +{ + PyObject* small_stack[_PyStack_SIZE]; + PyObject **stack; + int na; + fastternaryfunc meth = (fastternaryfunc)PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + PyObject *result; + + assert((PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) == METH_FASTCALL); + + stack = _PyStack_FromTuple(small_stack, Py_ARRAY_LENGTH(small_stack), + args, &na); + + result = (*meth)(self, stack, na, kwargs); + _PyStack_Free(stack, small_stack, na); + return result; +} + PyObject * PyCFunction_Call(PyObject *func, PyObject *args, PyObject *kwds) { @@ -97,6 +117,9 @@ PyCFunction_Call(PyObject *func, PyObjec if (flags == (METH_VARARGS | METH_KEYWORDS)) { res = (*(PyCFunctionWithKeywords)meth)(self, args, kwds); } + else if (flags == METH_FASTCALL) { + res = PyCFunction_FastCall_FromArgs(func, args, kwds); + } else { if (kwds != NULL && PyDict_Size(kwds) != 0) { PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", @@ -145,6 +168,116 @@ PyCFunction_Call(PyObject *func, PyObjec return _Py_CheckFunctionResult(func, res, NULL); } +PyObject * +_PyCFunction_FastCall(PyObject *func_obj, PyObject **stack, int nargs, + PyObject *kwargs) +{ + PyCFunctionObject* func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + PyObject *args, *result; + int flags; + + /* PyCFunction_Call() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + + flags = PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); + + switch (flags) + { + case METH_FASTCALL: + result = (*(fastternaryfunc)meth) (self, stack, nargs, kwargs); + break; + + case METH_NOARGS: + if (kwargs != NULL && PyDict_Size(kwargs) != 0) { + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + func->m_ml->ml_name); + return NULL; + } + + if (nargs != 0) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%zd given)", + func->m_ml->ml_name, nargs); + return NULL; + } + + result = (*meth) (self, NULL); + break; + + case METH_O: + if (kwargs != NULL && PyDict_Size(kwargs) != 0) { + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + func->m_ml->ml_name); + return NULL; + } + + if (nargs != 1) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%zd given)", + func->m_ml->ml_name, nargs); + return NULL; + } + + result = (*meth) (self, stack[0]); + break; + + case METH_VARARGS: + case METH_VARARGS | METH_KEYWORDS: + /* Slow-path: create a temporary tuple */ + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + return NULL; + } + + if (flags & METH_KEYWORDS) { + result = (*(PyCFunctionWithKeywords)meth) (self, args, kwargs); + } + else { + if (kwargs != NULL && PyDict_Size(kwargs) != 0) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes no keyword arguments", + func->m_ml->ml_name); + return NULL; + } + + result = (*meth) (self, args); + } + Py_DECREF(args); + break; + + default: + PyErr_SetString(PyExc_SystemError, + "Bad call flags in PyCFunction_Call. " + "METH_OLDARGS is no longer supported!"); + return NULL; + } + + result = _Py_CheckFunctionResult(func_obj, result, NULL); + + return result; +} + +PyObject * +_PyCFunction_FastCall_FromArgs(PyObject *func, PyObject *args, PyObject *kwargs) +{ + PyObject **stack; + int nargs; + int flags; + + flags = PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); + if (flags & METH_VARARGS) { + return PyCFunction_Call(func, args, kwargs); + } + + stack = _PyStack_FromBorrowedTuple(args, 0, &nargs); + return _PyCFunction_FastCall(func, stack, nargs, kwargs); + +} + /* Methods (the standard built-in methods, that is) */ static void @@ -349,12 +482,12 @@ PyTypeObject PyCFunction_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)meth_hash, /* tp_hash */ - PyCFunction_Call, /* tp_call */ + (ternaryfunc)_PyCFunction_FastCall, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_FASTCALL, /* tp_flags */ 0, /* tp_doc */ (traverseproc)meth_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -365,8 +498,6 @@ PyTypeObject PyCFunction_Type = { meth_methods, /* tp_methods */ meth_members, /* tp_members */ meth_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ }; /* Clear out the free list */ diff -r 496e094f4734 -r 34456cce64bb Objects/object.c --- a/Objects/object.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/object.c Thu May 19 13:47:42 2016 +0200 @@ -593,7 +593,7 @@ PyObject_Bytes(PyObject *v) func = _PyObject_LookupSpecial(v, &PyId___bytes__); if (func != NULL) { - result = PyObject_CallFunctionObjArgs(func, NULL); + result = PyObject_CallNoArg(func); Py_DECREF(func); if (result == NULL) return NULL; @@ -1311,7 +1311,7 @@ static PyObject * return NULL; } /* use __dir__ */ - result = PyObject_CallFunctionObjArgs(dirfunc, NULL); + result = PyObject_CallNoArg(dirfunc); Py_DECREF(dirfunc); if (result == NULL) return NULL; diff -r 496e094f4734 -r 34456cce64bb Objects/odictobject.c --- a/Objects/odictobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/odictobject.c Thu May 19 13:47:42 2016 +0200 @@ -1654,7 +1654,7 @@ odict_new(PyTypeObject *type, PyObject * { PyODictObject *od; - od = (PyODictObject *)PyDict_Type.tp_new(type, args, kwds); + od = (PyODictObject *)_PyType_CallNew(&PyDict_Type, type, args, kwds); if (od == NULL) return NULL; diff -r 496e094f4734 -r 34456cce64bb Objects/rangeobject.c --- a/Objects/rangeobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/rangeobject.c Thu May 19 13:47:42 2016 +0200 @@ -76,7 +76,7 @@ make_range_object(PyTypeObject *type, Py range(0, 5, -1) */ static PyObject * -range_new(PyTypeObject *type, PyObject *args, PyObject *kw) +range_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kw) { rangeobject *obj; PyObject *start = NULL, *stop = NULL, *step = NULL; @@ -84,8 +84,8 @@ range_new(PyTypeObject *type, PyObject * if (!_PyArg_NoKeywords("range()", kw)) return NULL; - if (PyTuple_Size(args) <= 1) { - if (!PyArg_UnpackTuple(args, "range", 1, 1, &stop)) + if (nargs <= 1) { + if (!PyArg_UnpackStack(stack, nargs, "range", 1, 1, &stop)) return NULL; stop = PyNumber_Index(stop); if (!stop) @@ -103,7 +103,7 @@ range_new(PyTypeObject *type, PyObject * } } else { - if (!PyArg_UnpackTuple(args, "range", 2, 3, + if (!PyArg_UnpackStack(stack, nargs, "range", 2, 3, &start, &stop, &step)) return NULL; @@ -723,7 +723,7 @@ PyTypeObject PyRange_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_FASTNEW, /* tp_flags */ range_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -741,7 +741,7 @@ PyTypeObject PyRange_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - range_new, /* tp_new */ + (newfunc)range_new, /* tp_new */ }; /*********************** range Iterator **************************/ diff -r 496e094f4734 -r 34456cce64bb Objects/tupleobject.c --- a/Objects/tupleobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/tupleobject.c Thu May 19 13:47:42 2016 +0200 @@ -634,17 +634,18 @@ tuplerichcompare(PyObject *v, PyObject * } static PyObject * -tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +tuple_subtype_new(PyTypeObject *type, PyObject **stack, int na, PyObject *kwargs); static PyObject * -tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +tuple_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { + static char *kwlist[] = {"sequence", 0}; PyObject *arg = NULL; - static char *kwlist[] = {"sequence", 0}; if (type != &PyTuple_Type) - return tuple_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:tuple", kwlist, &arg)) + return tuple_subtype_new(type, stack, nargs, kwds); + + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|O:tuple", kwlist, &arg)) return NULL; if (arg == NULL) @@ -654,13 +655,13 @@ tuple_new(PyTypeObject *type, PyObject * } static PyObject * -tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +tuple_subtype_new(PyTypeObject *type, PyObject **stack, int na, PyObject *kwargs) { PyObject *tmp, *newobj, *item; Py_ssize_t i, n; assert(PyType_IsSubtype(type, &PyTuple_Type)); - tmp = tuple_new(&PyTuple_Type, args, kwds); + tmp = tuple_new(&PyTuple_Type, stack, na, kwargs); if (tmp == NULL) return NULL; assert(PyTuple_Check(tmp)); @@ -798,8 +799,8 @@ PyTypeObject PyTuple_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_TUPLE_SUBCLASS| Py_TPFLAGS_FASTNEW, /* tp_flags */ tuple_doc, /* tp_doc */ (traverseproc)tupletraverse, /* tp_traverse */ 0, /* tp_clear */ @@ -817,7 +818,7 @@ PyTypeObject PyTuple_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - tuple_new, /* tp_new */ + (newfunc)tuple_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/typeobject.c --- a/Objects/typeobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/typeobject.c Thu May 19 13:47:42 2016 +0200 @@ -6,6 +6,20 @@ #include +/* Forward declaration */ +static int slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds); +static int slot_tp_fastinit(PyObject *self, PyObject **stack, int na, PyObject *kwargs); +static PyObject * slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +static PyObject * slot_tp_fastnew(PyTypeObject *type, PyObject **stack, int na, PyObject *kwargs); +static void clear_slotdefs(void); +static int object_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds); +static PyObject * object_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds); +static void object_dealloc(PyObject *); +static int update_slot(PyTypeObject *, PyObject *); +static void fixup_slot_dispatchers(PyTypeObject *); +static void fixup_fast_slots(PyTypeObject *type); +/* FIXME: don't forward declare, keep it private */ +static int super_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds); /* Support type attribute cache */ @@ -60,12 +74,6 @@ static size_t method_cache_collisions = _Py_IDENTIFIER(__setitem__); _Py_IDENTIFIER(builtins); -static PyObject * -slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static void -clear_slotdefs(void); - /* * finds the beginning of the docstring's introspection signature. * if present, returns a pointer pointing to the first '('. @@ -868,8 +876,94 @@ type_repr(PyTypeObject *type) return rtn; } +typedef PyObject *(*fastnewfunc) (PyTypeObject *type, + PyObject **stack, int na, PyObject *kwargs); + +PyObject* +_PyType_CallNew(PyTypeObject *type_new, + PyTypeObject *type_arg, PyObject *args, PyObject *kwds) +{ + PyObject **stack; + int nargs; + PyObject *result; + fastnewfunc fastnew; + + if (!(type_new->tp_flags & Py_TPFLAGS_FASTNEW)) { + return type_new->tp_new(type_arg, args, kwds); + } + + fastnew = (fastnewfunc)type_new->tp_new; + stack = _PyStack_FromBorrowedTuple(args, 0, &nargs); + result = fastnew(type_arg, stack, nargs, kwds); + + return result; +} + +int +_PyType_CallInit(PyTypeObject *type, PyObject *obj, PyObject *args, PyObject *kwds) +{ + PyObject **stack; + int nargs; + int result; + fastinitproc fastinit; + + if (!(type->tp_flags & Py_TPFLAGS_FASTINIT)) { + return type->tp_init(obj, args, kwds); + } + + fastinit = (fastinitproc)type->tp_init; + stack = _PyStack_FromBorrowedTuple(args, 0, &nargs); + result = fastinit(obj, stack, nargs, kwds); + + return result; +} + +static PyObject* +type_call_fastnew(PyTypeObject *type, PyObject **stack, int na, PyObject *kwargs) +{ + PyObject *args; + PyObject *result; + + if (type->tp_flags & Py_TPFLAGS_FASTNEW) { + fastnewfunc fastnew = (fastnewfunc)type->tp_new; + return fastnew(type, stack, na, kwargs); + } + + args = _PyStack_AsTuple(stack, na); + if (args == NULL) { + return NULL; + } + + result = type->tp_new(type, args, kwargs); + Py_DECREF(args); + + return result; +} + +static int +type_call_fastinit(PyTypeObject *type, PyObject *obj, PyObject **stack, int na, PyObject *kwargs) +{ + PyObject *args; + int result; + + if (type->tp_flags & Py_TPFLAGS_FASTINIT) { + fastinitproc fastinit = (fastinitproc)type->tp_init; + return fastinit(obj, stack, na, kwargs); + } + + args = _PyStack_AsTuple(stack, na); + if (args == NULL) { + return -1; + } + + result = type->tp_init(obj, args, kwargs); + Py_DECREF(args); + + return result; +} + static PyObject * -type_call(PyTypeObject *type, PyObject *args, PyObject *kwds) +type_call(PyTypeObject *type, PyObject **stack, int na, PyObject *kwds) { PyObject *obj; @@ -887,16 +981,14 @@ type_call(PyTypeObject *type, PyObject * assert(!PyErr_Occurred()); #endif - obj = type->tp_new(type, args, kwds); + obj = type_call_fastnew(type, stack, na, kwds); obj = _Py_CheckFunctionResult((PyObject*)type, obj, NULL); if (obj == NULL) return NULL; /* Ugly exception: when the call was type(something), don't call tp_init on the result. */ - if (type == &PyType_Type && - PyTuple_Check(args) && PyTuple_GET_SIZE(args) == 1 && - (kwds == NULL || + if (type == &PyType_Type && na == 1 && (kwds == NULL || (PyDict_Check(kwds) && PyDict_Size(kwds) == 0))) return obj; @@ -907,7 +999,9 @@ type_call(PyTypeObject *type, PyObject * type = Py_TYPE(obj); if (type->tp_init != NULL) { - int res = type->tp_init(obj, args, kwds); + int res; + + res = type_call_fastinit(type, obj, stack, na, kwds); if (res < 0) { assert(PyErr_Occurred()); Py_DECREF(obj); @@ -956,6 +1050,12 @@ PyType_GenericNew(PyTypeObject *type, Py return type->tp_alloc(type, 0); } +PyObject * +_PyType_FastGenericNew(PyTypeObject *type, PyObject **stack, int nargs, PyObject **kwds) +{ + return type->tp_alloc(type, 0); +} + /* Helpers for subtyping */ static int @@ -1419,73 +1519,83 @@ PyObject * as lookup_method to cache the interned name string object. */ static PyObject * -call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...) -{ - va_list va; - PyObject *args, *func = 0, *retval; - va_start(va, format); +get_method(PyObject *o, _Py_Identifier *nameid) +{ + PyObject *func; func = lookup_maybe(o, nameid); if (func == NULL) { - va_end(va); - if (!PyErr_Occurred()) + if (!PyErr_Occurred()) { PyErr_SetObject(PyExc_AttributeError, nameid->object); - return NULL; - } - - if (format && *format) - args = Py_VaBuildValue(format, va); - else - args = PyTuple_New(0); - - va_end(va); - - if (args == NULL) - return NULL; - - assert(PyTuple_Check(args)); - retval = PyObject_Call(func, args, NULL); - - Py_DECREF(args); + } + return NULL; + } + return func; +} + +static PyObject * +call_method_noarg(PyObject *o, _Py_Identifier *nameid) +{ + PyObject *func, *result; + + func = get_method(o, nameid); + if (func == NULL) { + return NULL; + } + + result = PyObject_CallNoArg(func); Py_DECREF(func); - - return retval; -} - -/* Clone of call_method() that returns NotImplemented when the lookup fails. */ + return result; +} static PyObject * -call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...) -{ - va_list va; - PyObject *args, *func = 0, *retval; - va_start(va, format); +call_method_arg1(PyObject *o, _Py_Identifier *nameid, PyObject *arg) +{ + PyObject *func, *result; + + func = get_method(o, nameid); + if (func == NULL) { + return NULL; + } + + result = PyObject_CallArg1(func, arg); + Py_DECREF(func); + return result; +} + +static PyObject * +call_method_arg2(PyObject *o, _Py_Identifier *nameid, PyObject *arg1, PyObject *arg2) +{ + PyObject *func, *result; + PyObject* stack[2]; + + func = get_method(o, nameid); + if (func == NULL) { + return NULL; + } + + stack[0] = arg1; + stack[1] = arg2; + result = _PyObject_FastCall(func, stack, 2, 0); + Py_DECREF(func); + return result; +} + +/* Clone of call_method_arg1() that returns NotImplemented when the lookup fails. */ + +static PyObject * +call_maybe_arg1(PyObject *o, _Py_Identifier *nameid, PyObject *arg) +{ + PyObject *func; func = lookup_maybe(o, nameid); if (func == NULL) { - va_end(va); if (!PyErr_Occurred()) Py_RETURN_NOTIMPLEMENTED; return NULL; } - if (format && *format) - args = Py_VaBuildValue(format, va); - else - args = PyTuple_New(0); - - va_end(va); - - if (args == NULL) - return NULL; - - assert(PyTuple_Check(args)); - retval = PyObject_Call(func, args, NULL); - - Py_DECREF(args); - Py_DECREF(func); - - return retval; + return PyObject_CallArg1(func, arg); } /* @@ -1843,7 +1953,7 @@ mro_invoke(PyTypeObject *type) PyObject *mro_meth = lookup_method((PyObject *)type, &PyId_mro); if (mro_meth == NULL) return NULL; - mro_result = PyObject_CallObject(mro_meth, NULL); + mro_result = PyObject_CallNoArg(mro_meth); Py_DECREF(mro_meth); } else { @@ -2024,11 +2134,6 @@ solid_base(PyTypeObject *type) return base; } -static void object_dealloc(PyObject *); -static int object_init(PyObject *, PyObject *, PyObject *); -static int update_slot(PyTypeObject *, PyObject *); -static void fixup_slot_dispatchers(PyTypeObject *); - /* * Helpers for __dict__ descriptor. We don't want to expose the dicts * inherited from various builtin types. The builtin base usually provides @@ -2192,15 +2297,10 @@ valid_identifier(PyObject *s) } /* Forward */ + static int -object_init(PyObject *self, PyObject *args, PyObject *kwds); - -static int -type_init(PyObject *cls, PyObject *args, PyObject *kwds) -{ - int res; - - assert(args != NULL && PyTuple_Check(args)); +type_init(PyObject *cls, PyObject **stack, int nargs, PyObject *kwds) +{ assert(kwds == NULL || PyDict_Check(kwds)); if (kwds != NULL && PyDict_Check(kwds) && PyDict_Size(kwds) != 0) { @@ -2209,8 +2309,7 @@ type_init(PyObject *cls, PyObject *args, return -1; } - if (args != NULL && PyTuple_Check(args) && - (PyTuple_GET_SIZE(args) != 1 && PyTuple_GET_SIZE(args) != 3)) { + if (nargs != 1 && nargs != 3) { PyErr_SetString(PyExc_TypeError, "type.__init__() takes 1 or 3 arguments"); return -1; @@ -2218,10 +2317,7 @@ type_init(PyObject *cls, PyObject *args, /* Call object.__init__(self) now. */ /* XXX Could call super(type, cls).__init__() but what's the point? */ - args = PyTuple_GetSlice(args, 0, 0); - res = object_init(cls, args, NULL); - Py_DECREF(args); - return res; + return object_init(cls, stack, 0, NULL); } unsigned long @@ -2267,7 +2363,7 @@ PyTypeObject * } static PyObject * -type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) +type_new(PyTypeObject *metatype, PyObject **stack, int nargs, PyObject *kwds) { PyObject *name, *bases = NULL, *orig_dict, *dict = NULL; static char *kwlist[] = {"name", "bases", "dict", 0}; @@ -2280,16 +2376,14 @@ type_new(PyTypeObject *metatype, PyObjec _Py_IDENTIFIER(__qualname__); _Py_IDENTIFIER(__slots__); - assert(args != NULL && PyTuple_Check(args)); assert(kwds == NULL || PyDict_Check(kwds)); /* Special case: type(x) should return x->ob_type */ { - const Py_ssize_t nargs = PyTuple_GET_SIZE(args); const Py_ssize_t nkwds = kwds == NULL ? 0 : PyDict_Size(kwds); if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) { - PyObject *x = PyTuple_GET_ITEM(args, 0); + PyObject *x = stack[0]; Py_INCREF(Py_TYPE(x)); return (PyObject *) Py_TYPE(x); } @@ -2305,7 +2399,7 @@ type_new(PyTypeObject *metatype, PyObjec } /* Check arguments: (name, bases, dict) */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "UO!O!:type", kwlist, &name, &PyTuple_Type, &bases, &PyDict_Type, &orig_dict)) @@ -2318,8 +2412,9 @@ type_new(PyTypeObject *metatype, PyObjec } if (winner != metatype) { - if (winner->tp_new != type_new) /* Pass it to the winner */ - return winner->tp_new(winner, args, kwds); + if (winner->tp_new != (newfunc)type_new) /* Pass it to the winner */ { + return type_call_fastnew(winner, stack, nargs, kwds); + } metatype = winner; } @@ -3080,7 +3175,7 @@ type_subclasses(PyTypeObject *type, PyOb } static PyObject * -type_prepare(PyObject *self, PyObject *args, PyObject *kwds) +type_prepare(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { return PyDict_New(); } @@ -3184,7 +3279,7 @@ static PyMethodDef type_methods[] = { {"__subclasses__", (PyCFunction)type_subclasses, METH_NOARGS, PyDoc_STR("__subclasses__() -> list of immediate subclasses")}, {"__prepare__", (PyCFunction)type_prepare, - METH_VARARGS | METH_KEYWORDS | METH_CLASS, + METH_FASTCALL | METH_CLASS, PyDoc_STR("__prepare__() -> dict\n" "used to create the namespace for the class statement")}, {"__instancecheck__", type___instancecheck__, METH_O, @@ -3303,8 +3398,10 @@ PyTypeObject PyType_Type = { (getattrofunc)type_getattro, /* tp_getattro */ (setattrofunc)type_setattro, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC + | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT + | Py_TPFLAGS_FASTCALL, /* tp_flags */ type_doc, /* tp_doc */ (traverseproc)type_traverse, /* tp_traverse */ (inquiry)type_clear, /* tp_clear */ @@ -3320,9 +3417,9 @@ PyTypeObject PyType_Type = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ offsetof(PyTypeObject, tp_dict), /* tp_dictoffset */ - type_init, /* tp_init */ + (initproc)type_init, /* tp_init */ 0, /* tp_alloc */ - type_new, /* tp_new */ + (newfunc)type_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ (inquiry)type_is_gc, /* tp_is_gc */ }; @@ -3370,24 +3467,20 @@ PyTypeObject PyType_Type = { */ -/* Forward */ -static PyObject * -object_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - static int -excess_args(PyObject *args, PyObject *kwds) -{ - return PyTuple_GET_SIZE(args) || +excess_args(int nargs, PyObject *kwds) +{ + return nargs || (kwds && PyDict_Check(kwds) && PyDict_Size(kwds)); } static int -object_init(PyObject *self, PyObject *args, PyObject *kwds) +object_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { int err = 0; PyTypeObject *type = Py_TYPE(self); - if (excess_args(args, kwds) && - (type->tp_new == object_new || type->tp_init != object_init)) { + if (excess_args(nargs, kwds) && + (type->tp_new == (newfunc)object_new || type->tp_init != (initproc)object_init)) { PyErr_SetString(PyExc_TypeError, "object.__init__() takes no parameters"); err = -1; } @@ -3395,10 +3488,11 @@ object_init(PyObject *self, PyObject *ar } static PyObject * -object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - if (excess_args(args, kwds) && - (type->tp_init == object_init || type->tp_new != object_new)) { +object_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) +{ + if (excess_args(nargs, kwds) && + (type->tp_init == (initproc)object_init + || type->tp_new != (newfunc)object_new)) { PyErr_SetString(PyExc_TypeError, "object() takes no parameters"); return NULL; } @@ -3424,9 +3518,7 @@ object_new(PyTypeObject *type, PyObject sorted = _PyDict_GetItemId(builtins, &PyId_sorted); if (sorted == NULL) goto error; - sorted_methods = PyObject_CallFunctionObjArgs(sorted, - abstract_methods, - NULL); + sorted_methods = PyObject_CallArg1(sorted, abstract_methods); if (sorted_methods == NULL) goto error; comma = _PyUnicode_FromId(&comma_id); @@ -3962,7 +4054,7 @@ Py_LOCAL(PyObject *) Py_DECREF(slotnames); } else { /* getstate != NULL */ - state = PyObject_CallObject(getstate, NULL); + state = PyObject_CallNoArg(getstate); Py_DECREF(getstate); if (state == NULL) return NULL; @@ -3987,7 +4079,7 @@ Py_LOCAL(int) __getnewargs_ex__ on the object. */ getnewargs_ex = _PyObject_LookupSpecial(obj, &PyId___getnewargs_ex__); if (getnewargs_ex != NULL) { - PyObject *newargs = PyObject_CallObject(getnewargs_ex, NULL); + PyObject *newargs = PyObject_CallNoArg(getnewargs_ex); Py_DECREF(getnewargs_ex); if (newargs == NULL) { return -1; @@ -4040,7 +4132,7 @@ Py_LOCAL(int) __getnewargs__ instead. */ getnewargs = _PyObject_LookupSpecial(obj, &PyId___getnewargs__); if (getnewargs != NULL) { - *args = PyObject_CallObject(getnewargs, NULL); + *args = PyObject_CallNoArg(getnewargs); Py_DECREF(getnewargs); if (*args == NULL) { return -1; @@ -4235,32 +4327,36 @@ static PyObject * if (!copyreg) return NULL; - res = PyEval_CallMethod(copyreg, "_reduce_ex", "(Oi)", self, proto); + res = PyObject_CallMethod(copyreg, "_reduce_ex", "Oi", self, proto); Py_DECREF(copyreg); return res; } static PyObject * -object_reduce(PyObject *self, PyObject *args) +object_reduce(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { int proto = 0; - if (!PyArg_ParseTuple(args, "|i:__reduce__", &proto)) + if (!PyArg_ParseStack(stack, nargs, "|i:__reduce__", &proto)) + return NULL; + if (kwargs != NULL && !_PyArg_NoKeywords("object.__reduce__", kwargs)) return NULL; return _common_reduce(self, proto); } static PyObject * -object_reduce_ex(PyObject *self, PyObject *args) +object_reduce_ex(PyObject *self, PyObject **stack, int nargs, PyObject *kwargs) { static PyObject *objreduce; PyObject *reduce, *res; int proto = 0; _Py_IDENTIFIER(__reduce__); - if (!PyArg_ParseTuple(args, "|i:__reduce_ex__", &proto)) + if (!PyArg_ParseStack(stack, nargs, "|i:__reduce_ex__", &proto)) + return NULL; + if (kwargs != NULL && !_PyArg_NoKeywords("object.__reduce_ex__", kwargs)) return NULL; if (objreduce == NULL) { @@ -4286,7 +4382,7 @@ object_reduce_ex(PyObject *self, PyObjec override = (clsreduce != objreduce); Py_DECREF(clsreduce); if (override) { - res = PyObject_CallObject(reduce, NULL); + res = PyObject_CallNoArg(reduce); Py_DECREF(reduce); return res; } @@ -4409,9 +4505,9 @@ error: } static PyMethodDef object_methods[] = { - {"__reduce_ex__", object_reduce_ex, METH_VARARGS, + {"__reduce_ex__", (PyCFunction)object_reduce_ex, METH_FASTCALL, PyDoc_STR("helper for pickle")}, - {"__reduce__", object_reduce, METH_VARARGS, + {"__reduce__", (PyCFunction)object_reduce, METH_FASTCALL, PyDoc_STR("helper for pickle")}, {"__subclasshook__", object_subclasshook, METH_CLASS | METH_VARARGS, object_subclasshook_doc}, @@ -4445,7 +4541,8 @@ PyTypeObject PyBaseObject_Type = { PyObject_GenericGetAttr, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_FASTNEW | Py_TPFLAGS_FASTINIT, /* tp_flags */ PyDoc_STR("object()\n--\n\nThe most base type"), /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -4461,9 +4558,9 @@ PyTypeObject PyBaseObject_Type = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - object_init, /* tp_init */ + (initproc)object_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - object_new, /* tp_new */ + (newfunc)object_new, /* tp_new */ PyObject_Del, /* tp_free */ }; @@ -4575,8 +4672,12 @@ inherit_special(PyTypeObject *type, PyTy inherit object.__new__. */ if (base != &PyBaseObject_Type || (type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { - if (type->tp_new == NULL) + if (type->tp_new == NULL) { type->tp_new = base->tp_new; + if (base->tp_flags & Py_TPFLAGS_FASTNEW) { + type->tp_flags |= Py_TPFLAGS_FASTNEW; + } + } } } if (type->tp_basicsize == 0) @@ -4748,7 +4849,12 @@ inherit_slots(PyTypeObject *type, PyType /* tp_reserved is ignored */ COPYSLOT(tp_repr); /* tp_hash see tp_richcompare */ - COPYSLOT(tp_call); + if (!type->tp_call && SLOTDEFINED(tp_call)) { + type->tp_call = base->tp_call; + if (base->tp_flags & Py_TPFLAGS_FASTCALL) { + type->tp_flags |= Py_TPFLAGS_FASTCALL; + } + } COPYSLOT(tp_str); { /* Copy comparison-related slots only when @@ -4769,7 +4875,12 @@ inherit_slots(PyTypeObject *type, PyType COPYSLOT(tp_descr_get); COPYSLOT(tp_descr_set); COPYSLOT(tp_dictoffset); - COPYSLOT(tp_init); + if (!type->tp_init && SLOTDEFINED(tp_init)) { + type->tp_init = base->tp_init; + if (base->tp_flags & Py_TPFLAGS_FASTINIT) { + type->tp_flags |= Py_TPFLAGS_FASTINIT; + } + } COPYSLOT(tp_alloc); COPYSLOT(tp_is_gc); if ((type->tp_flags & Py_TPFLAGS_HAVE_FINALIZE) && @@ -4998,6 +5109,9 @@ PyType_Ready(PyTypeObject *type) assert(type->tp_dict != NULL); type->tp_flags = (type->tp_flags & ~Py_TPFLAGS_READYING) | Py_TPFLAGS_READY; + + fixup_fast_slots(type); + return 0; error: @@ -5082,19 +5196,25 @@ remove_all_subclasses(PyTypeObject *type } static int -check_num_args(PyObject *ob, int n) +check_stack_num_args(Py_ssize_t na, Py_ssize_t n) +{ + if (n == na) + return 1; + PyErr_Format( + PyExc_TypeError, + "expected %zd arguments, got %zd", n, na); + return 0; +} + +static int +check_num_args(PyObject *ob, Py_ssize_t n) { if (!PyTuple_CheckExact(ob)) { PyErr_SetString(PyExc_SystemError, "PyArg_UnpackTuple() argument list is not a tuple"); return 0; } - if (n == PyTuple_GET_SIZE(ob)) - return 1; - PyErr_Format( - PyExc_TypeError, - "expected %d arguments, got %zd", n, PyTuple_GET_SIZE(ob)); - return 0; + return check_stack_num_args(PyTuple_GET_SIZE(ob), n); } /* Generic wrappers for overloadable 'operators' such as __getitem__ */ @@ -5106,12 +5226,12 @@ check_num_args(PyObject *ob, int n) entries, one regular and one with reversed arguments. */ static PyObject * -wrap_lenfunc(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_lenfunc(PyObject *self, PyObject **stack, int na, void *wrapped) { lenfunc func = (lenfunc)wrapped; Py_ssize_t res; - if (!check_num_args(args, 0)) + if (!check_stack_num_args(na, 0)) return NULL; res = (*func)(self); if (res == -1 && PyErr_Occurred()) @@ -5120,12 +5240,26 @@ wrap_lenfunc(PyObject *self, PyObject *a } static PyObject * -wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped) +wrap_lenfunc(PyObject *self, PyObject *args, void *wrapped) +{ + lenfunc func = (lenfunc)wrapped; + Py_ssize_t res; + + if (!check_num_args(args, 0)) + return NULL; + res = (*func)(self); + if (res == -1 && PyErr_Occurred()) + return NULL; + return PyLong_FromLong((long)res); +} + +static PyObject * +wrap_fast_inquirypred(PyObject *self, PyObject **stack, int na, void *wrapped) { inquiry func = (inquiry)wrapped; int res; - if (!check_num_args(args, 0)) + if (!check_stack_num_args(na, 0)) return NULL; res = (*func)(self); if (res == -1 && PyErr_Occurred()) @@ -5134,11 +5268,37 @@ wrap_inquirypred(PyObject *self, PyObjec } static PyObject * -wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped) +wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped) +{ + inquiry func = (inquiry)wrapped; + int res; + + if (!check_num_args(args, 0)) + return NULL; + res = (*func)(self); + if (res == -1 && PyErr_Occurred()) + return NULL; + return PyBool_FromLong((long)res); +} + +static PyObject * +wrap_fast_binaryfunc(PyObject *self, PyObject **stack, int na, void *wrapped) { binaryfunc func = (binaryfunc)wrapped; PyObject *other; + if (!check_stack_num_args(na, 1)) + return NULL; + other = stack[0]; + return (*func)(self, other); +} + +static PyObject * +wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped) +{ + binaryfunc func = (binaryfunc)wrapped; + PyObject *other; + if (!check_num_args(args, 1)) return NULL; other = PyTuple_GET_ITEM(args, 0); @@ -5146,11 +5306,31 @@ wrap_binaryfunc(PyObject *self, PyObject } static PyObject * -wrap_binaryfunc_l(PyObject *self, PyObject *args, void *wrapped) -{ +wrap_fast_binaryfunc_l(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + /* wrap_fast_binaryfunc_l() has the same code than wrap_fast_binaryfunc() + but both functions must have a different address for + "d->d_base->wrapper == p->wrapper" tests: + http://bugs.python.org/issue8847#msg166935 */ binaryfunc func = (binaryfunc)wrapped; PyObject *other; + if (!check_stack_num_args(na, 1)) + return NULL; + other = stack[0]; + return (*func)(self, other); +} + +static PyObject * +wrap_binaryfunc_l(PyObject *self, PyObject *args, void *wrapped) +{ + /* wrap_binaryfunc_l() has the same code than wrap_binaryfunc() + but both functions must have a different address for + "d->d_base->wrapper == p->wrapper" tests: + http://bugs.python.org/issue8847#msg166935 */ + binaryfunc func = (binaryfunc)wrapped; + PyObject *other; + if (!check_num_args(args, 1)) return NULL; other = PyTuple_GET_ITEM(args, 0); @@ -5170,7 +5350,7 @@ wrap_binaryfunc_r(PyObject *self, PyObje } static PyObject * -wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_pow(PyObject *self, PyObject **stack, int na, void *wrapped) { ternaryfunc func = (ternaryfunc)wrapped; PyObject *other; @@ -5178,26 +5358,66 @@ wrap_ternaryfunc(PyObject *self, PyObjec /* Note: This wrapper only works for __pow__() */ - if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third)) - return NULL; + if (_PyStack_CheckArgs(stack, na, 0, "__pow__", 1, 2) < 0) { + return NULL; + } + other = stack[0]; + third = (na >= 2) ? stack[1] : Py_None; + return (*func)(self, other, third); } static PyObject * -wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped) +wrap_pow(PyObject *self, PyObject *args, void *wrapped) { ternaryfunc func = (ternaryfunc)wrapped; PyObject *other; PyObject *third = Py_None; - /* Note: This wrapper only works for __pow__() */ - if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third)) return NULL; + return (*func)(self, other, third); +} + +static PyObject * +wrap_fast_rpow(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + ternaryfunc func = (ternaryfunc)wrapped; + PyObject *other; + PyObject *third = Py_None; + + if (_PyStack_CheckArgs(stack, na, 0, "__pow__", 1, 2) < 0) { + return NULL; + } + other = stack[0]; + third = (na >= 2) ? stack[1] : Py_None; + return (*func)(other, self, third); } static PyObject * +wrap_rpow(PyObject *self, PyObject *args, void *wrapped) +{ + ternaryfunc func = (ternaryfunc)wrapped; + PyObject *other; + PyObject *third = Py_None; + + if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third)) + return NULL; + return (*func)(other, self, third); +} + +static PyObject * +wrap_fast_unaryfunc(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + unaryfunc func = (unaryfunc)wrapped; + + if (!check_stack_num_args(na, 0)) + return NULL; + return (*func)(self); +} + +static PyObject * wrap_unaryfunc(PyObject *self, PyObject *args, void *wrapped) { unaryfunc func = (unaryfunc)wrapped; @@ -5208,6 +5428,22 @@ wrap_unaryfunc(PyObject *self, PyObject } static PyObject * +wrap_fast_indexargfunc(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + ssizeargfunc func = (ssizeargfunc)wrapped; + PyObject* o; + Py_ssize_t i; + + if (!check_stack_num_args(na, 1)) + return NULL; + o = stack[0]; + i = PyNumber_AsSsize_t(o, PyExc_OverflowError); + if (i == -1 && PyErr_Occurred()) + return NULL; + return (*func)(self, i); +} + +static PyObject * wrap_indexargfunc(PyObject *self, PyObject *args, void *wrapped) { ssizeargfunc func = (ssizeargfunc)wrapped; @@ -5243,34 +5479,51 @@ getindex(PyObject *self, PyObject *arg) } static PyObject * -wrap_sq_item(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_sq_item(PyObject *self, PyObject **stack, int na, void *wrapped) { ssizeargfunc func = (ssizeargfunc)wrapped; PyObject *arg; Py_ssize_t i; - if (PyTuple_GET_SIZE(args) == 1) { - arg = PyTuple_GET_ITEM(args, 0); - i = getindex(self, arg); - if (i == -1 && PyErr_Occurred()) - return NULL; - return (*func)(self, i); - } - check_num_args(args, 1); - assert(PyErr_Occurred()); - return NULL; + if (!check_stack_num_args(na, 1)) + return NULL; + + arg = stack[0]; + i = getindex(self, arg); + if (i == -1 && PyErr_Occurred()) + return NULL; + return (*func)(self, i); } static PyObject * -wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped) +wrap_sq_item(PyObject *self, PyObject *args, void *wrapped) +{ + ssizeargfunc func = (ssizeargfunc)wrapped; + PyObject *arg; + Py_ssize_t i; + + if (!check_num_args(args, 1)) + return NULL; + + arg = PyTuple_GET_ITEM(args, 0); + i = getindex(self, arg); + if (i == -1 && PyErr_Occurred()) + return NULL; + return (*func)(self, i); +} + +static PyObject * +wrap_fast_sq_setitem(PyObject *self, PyObject **stack, int na, void *wrapped) { ssizeobjargproc func = (ssizeobjargproc)wrapped; Py_ssize_t i; int res; PyObject *arg, *value; - if (!PyArg_UnpackTuple(args, "", 2, 2, &arg, &value)) - return NULL; + if (!check_stack_num_args(na, 2)) + return NULL; + arg = stack[0]; + value = stack[1]; i = getindex(self, arg); if (i == -1 && PyErr_Occurred()) return NULL; @@ -5282,13 +5535,54 @@ wrap_sq_setitem(PyObject *self, PyObject } static PyObject * -wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped) +wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped) +{ + ssizeobjargproc func = (ssizeobjargproc)wrapped; + Py_ssize_t i; + int res; + PyObject *arg, *value; + + if (!PyArg_UnpackTuple(args, "", 2, 2, &arg, &value)) + return NULL; + i = getindex(self, arg); + if (i == -1 && PyErr_Occurred()) + return NULL; + res = (*func)(self, i, value); + if (res == -1 && PyErr_Occurred()) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +wrap_fast_sq_delitem(PyObject *self, PyObject **stack, int na, void *wrapped) { ssizeobjargproc func = (ssizeobjargproc)wrapped; Py_ssize_t i; int res; PyObject *arg; + if (!check_stack_num_args(na, 1)) + return NULL; + arg = stack[0]; + i = getindex(self, arg); + if (i == -1 && PyErr_Occurred()) + return NULL; + res = (*func)(self, i, NULL); + if (res == -1 && PyErr_Occurred()) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped) +{ + ssizeobjargproc func = (ssizeobjargproc)wrapped; + Py_ssize_t i; + int res; + PyObject *arg; + if (!check_num_args(args, 1)) return NULL; arg = PyTuple_GET_ITEM(args, 0); @@ -5304,12 +5598,29 @@ wrap_sq_delitem(PyObject *self, PyObject /* XXX objobjproc is a misnomer; should be objargpred */ static PyObject * -wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_objobjproc(PyObject *self, PyObject **stack, int na, void *wrapped) { objobjproc func = (objobjproc)wrapped; int res; PyObject *value; + if (!check_stack_num_args(na, 1)) + return NULL; + value = stack[0]; + res = (*func)(self, value); + if (res == -1 && PyErr_Occurred()) + return NULL; + else + return PyBool_FromLong(res); +} + +static PyObject * +wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped) +{ + objobjproc func = (objobjproc)wrapped; + int res; + PyObject *value; + if (!check_num_args(args, 1)) return NULL; value = PyTuple_GET_ITEM(args, 0); @@ -5321,12 +5632,30 @@ wrap_objobjproc(PyObject *self, PyObject } static PyObject * -wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_objobjargproc(PyObject *self, PyObject **stack, int na, void *wrapped) { objobjargproc func = (objobjargproc)wrapped; int res; PyObject *key, *value; + if (!check_stack_num_args(na, 2)) + return NULL; + key = stack[0]; + value = stack[1]; + res = (*func)(self, key, value); + if (res == -1 && PyErr_Occurred()) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped) +{ + objobjargproc func = (objobjargproc)wrapped; + int res; + PyObject *key, *value; + if (!PyArg_UnpackTuple(args, "", 2, 2, &key, &value)) return NULL; res = (*func)(self, key, value); @@ -5337,6 +5666,23 @@ wrap_objobjargproc(PyObject *self, PyObj } static PyObject * +wrap_fast_delitem(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + objobjargproc func = (objobjargproc)wrapped; + int res; + PyObject *key; + + if (!check_stack_num_args(na, 1)) + return NULL; + key = stack[0]; + res = (*func)(self, key, NULL); + if (res == -1 && PyErr_Occurred()) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * wrap_delitem(PyObject *self, PyObject *args, void *wrapped) { objobjargproc func = (objobjargproc)wrapped; @@ -5392,12 +5738,51 @@ wrap_setattr(PyObject *self, PyObject *a } static PyObject * -wrap_delattr(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_setattr(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + setattrofunc func = (setattrofunc)wrapped; + int res; + PyObject *name, *value; + + if (!check_stack_num_args(na, 2)) + return NULL; + name = stack[0]; + value = stack[1]; + if (!hackcheck(self, func, "__setattr__")) + return NULL; + res = (*func)(self, name, value); + if (res < 0) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +wrap_fast_delattr(PyObject *self, PyObject **stack, int na, void *wrapped) { setattrofunc func = (setattrofunc)wrapped; int res; PyObject *name; + if (!check_stack_num_args(na, 1)) + return NULL; + name = stack[0]; + if (!hackcheck(self, func, "__delattr__")) + return NULL; + res = (*func)(self, name, NULL); + if (res < 0) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +wrap_delattr(PyObject *self, PyObject *args, void *wrapped) +{ + setattrofunc func = (setattrofunc)wrapped; + int res; + PyObject *name; + if (!check_num_args(args, 1)) return NULL; name = PyTuple_GET_ITEM(args, 0); @@ -5411,12 +5796,12 @@ wrap_delattr(PyObject *self, PyObject *a } static PyObject * -wrap_hashfunc(PyObject *self, PyObject *args, void *wrapped) +wrap_fast_hashfunc(PyObject *self, PyObject **stack, int na, void *wrapped) { hashfunc func = (hashfunc)wrapped; Py_hash_t res; - if (!check_num_args(args, 0)) + if (!check_stack_num_args(na, 0)) return NULL; res = (*func)(self); if (res == -1 && PyErr_Occurred()) @@ -5425,11 +5810,42 @@ wrap_hashfunc(PyObject *self, PyObject * } static PyObject * -wrap_call(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds) -{ - ternaryfunc func = (ternaryfunc)wrapped; - - return (*func)(self, args, kwds); +wrap_hashfunc(PyObject *self, PyObject *args, void *wrapped) +{ + hashfunc func = (hashfunc)wrapped; + Py_hash_t res; + + if (!check_num_args(args, 0)) + return NULL; + res = (*func)(self); + if (res == -1 && PyErr_Occurred()) + return NULL; + return PyLong_FromSsize_t(res); +} + +static PyObject * +wrap_call(PyObject *self, void *wrapped, int type_flags, PyObject **stack, int nargs, PyObject *kwds) +{ + PyObject *result; + + if (type_flags & Py_TPFLAGS_FASTCALL) { + fastternaryfunc func = (fastternaryfunc)wrapped; + + result = (*func)(self, stack, nargs, kwds); + } + else { + ternaryfunc func = (ternaryfunc)wrapped; + PyObject *args; + + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + return NULL; + } + + result = (*func)(self, args, kwds); + Py_DECREF(args); + } + return result; } static PyObject * @@ -5472,6 +5888,20 @@ RICHCMP_WRAPPER(gt, Py_GT) RICHCMP_WRAPPER(ge, Py_GE) static PyObject * +wrap_fast_next(PyObject *self, PyObject **stack, int na, void *wrapped) +{ + unaryfunc func = (unaryfunc)wrapped; + PyObject *res; + + if (!check_stack_num_args(na, 0)) + return NULL; + res = (*func)(self); + if (res == NULL && !PyErr_Occurred()) + PyErr_SetNone(PyExc_StopIteration); + return res; +} + +static PyObject * wrap_next(PyObject *self, PyObject *args, void *wrapped) { unaryfunc func = (unaryfunc)wrapped; @@ -5507,6 +5937,27 @@ wrap_descr_get(PyObject *self, PyObject } static PyObject * +wrap_descr_fastget(PyObject *self, PyObject **stack, int nargs, void *wrapped) +{ + descrgetfunc func = (descrgetfunc)wrapped; + PyObject *obj; + PyObject *type = NULL; + + if (!PyArg_UnpackStack(stack, nargs, "", 1, 2, &obj, &type)) + return NULL; + if (obj == Py_None) + obj = NULL; + if (type == Py_None) + type = NULL; + if (type == NULL &&obj == NULL) { + PyErr_SetString(PyExc_TypeError, + "__get__(None, None) is invalid"); + return NULL; + } + return (*func)(self, obj, type); +} + +static PyObject * wrap_descr_set(PyObject *self, PyObject *args, void *wrapped) { descrsetfunc func = (descrsetfunc)wrapped; @@ -5523,6 +5974,22 @@ wrap_descr_set(PyObject *self, PyObject } static PyObject * +wrap_descr_fastset(PyObject *self, PyObject **stack, int nargs, void *wrapped) +{ + descrsetfunc func = (descrsetfunc)wrapped; + PyObject *obj, *value; + int ret; + + if (!PyArg_UnpackStack(stack, nargs, "", 2, 2, &obj, &value)) + return NULL; + ret = (*func)(self, obj, value); + if (ret < 0) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped) { descrsetfunc func = (descrsetfunc)wrapped; @@ -5540,17 +6007,53 @@ wrap_descr_delete(PyObject *self, PyObje } static PyObject * -wrap_init(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds) -{ - initproc func = (initproc)wrapped; - - if (func(self, args, kwds) < 0) +wrap_descr_fastdelete(PyObject *self, PyObject **stack, int nargs, void *wrapped) +{ + descrsetfunc func = (descrsetfunc)wrapped; + PyObject *obj; + int ret; + + if (!check_stack_num_args(nargs, 1)) + return NULL; + obj = stack[0]; + ret = (*func)(self, obj, NULL); + if (ret < 0) return NULL; Py_INCREF(Py_None); return Py_None; } static PyObject * +wrap_init(PyObject *self, void *wrapped, int type_flags, PyObject **stack, int nargs, PyObject *kwds) +{ + int res; + + if (type_flags & Py_TPFLAGS_FASTINIT) { + fastinitproc func = (fastinitproc)wrapped; + + res = func(self, stack, nargs, kwds); + } + else { + initproc func = (initproc)wrapped; + PyObject *args; + + args = _PyStack_AsTuple(stack, nargs); + if (args == NULL) { + return NULL; + } + + res = func(self, args, kwds); + Py_DECREF(args); + } + + if (res < 0) { + return NULL; + } + + Py_RETURN_NONE; +} + +static PyObject * tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds) { PyTypeObject *type, *subtype, *staticbase; @@ -5588,7 +6091,7 @@ tp_new_wrapper(PyObject *self, PyObject object.__new__(dict). To do this, we check that the most derived base that's not a heap type is this type. */ staticbase = subtype; - while (staticbase && (staticbase->tp_new == slot_tp_new)) + while (staticbase && (staticbase->tp_new == slot_tp_new || staticbase->tp_new == (newfunc)slot_tp_fastnew)) staticbase = staticbase->tp_base; /* If staticbase is NULL now, it is a really weird type. In the spirit of backwards compatibility (?), just shut up. */ @@ -5601,21 +6104,20 @@ tp_new_wrapper(PyObject *self, PyObject return NULL; } + /* FIXME: fastcall */ args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); if (args == NULL) return NULL; - res = type->tp_new(subtype, args, kwds); + res = _PyType_CallNew(type, subtype, args, kwds); Py_DECREF(args); return res; } -static struct PyMethodDef tp_new_methoddef[] = { +static struct PyMethodDef tp_new_methoddef = \ {"__new__", (PyCFunction)tp_new_wrapper, METH_VARARGS|METH_KEYWORDS, PyDoc_STR("__new__($type, *args, **kwargs)\n--\n\n" "Create and return a new object. " - "See help(type) for accurate signature.")}, - {0} -}; + "See help(type) for accurate signature.")}; static int add_tp_new_wrapper(PyTypeObject *type) @@ -5624,7 +6126,7 @@ add_tp_new_wrapper(PyTypeObject *type) if (_PyDict_GetItemId(type->tp_dict, &PyId___new__) != NULL) return 0; - func = PyCFunction_NewEx(tp_new_methoddef, (PyObject *)type, NULL); + func = PyCFunction_NewEx(&tp_new_methoddef, (PyObject *)type, NULL); if (func == NULL) return -1; if (_PyDict_SetItemId(type->tp_dict, &PyId___new__, func)) { @@ -5643,15 +6145,17 @@ static PyObject * \ FUNCNAME(PyObject *self) \ { \ _Py_static_string(id, OPSTR); \ - return call_method(self, &id, "()"); \ -} - -#define SLOT1(FUNCNAME, OPSTR, ARG1TYPE, ARGCODES) \ + \ + return call_method_noarg(self, &id); \ +} + +#define SLOT1(FUNCNAME, OPSTR, ARG1TYPE) \ static PyObject * \ -FUNCNAME(PyObject *self, ARG1TYPE arg1) \ +FUNCNAME(PyObject *self, ARG1TYPE arg) \ { \ _Py_static_string(id, OPSTR); \ - return call_method(self, &id, "(" ARGCODES ")", arg1); \ + \ + return call_method_arg1(self, &id, arg); \ } /* Boolean helper for SLOT1BINFULL(). @@ -5704,20 +6208,20 @@ FUNCNAME(PyObject *self, PyObject *other if (do_other && \ PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)) && \ method_is_overloaded(self, other, &rop_id)) { \ - r = call_maybe(other, &rop_id, "(O)", self); \ + r = call_maybe_arg1(other, &rop_id, self); \ if (r != Py_NotImplemented) \ return r; \ Py_DECREF(r); \ do_other = 0; \ } \ - r = call_maybe(self, &op_id, "(O)", other); \ + r = call_maybe_arg1(self, &op_id, other); \ if (r != Py_NotImplemented || \ Py_TYPE(other) == Py_TYPE(self)) \ return r; \ Py_DECREF(r); \ } \ if (do_other) { \ - return call_maybe(other, &rop_id, "(O)", self); \ + return call_maybe_arg1(other, &rop_id, self); \ } \ Py_RETURN_NOTIMPLEMENTED; \ } @@ -5725,22 +6229,18 @@ FUNCNAME(PyObject *self, PyObject *other #define SLOT1BIN(FUNCNAME, SLOTNAME, OPSTR, ROPSTR) \ SLOT1BINFULL(FUNCNAME, FUNCNAME, SLOTNAME, OPSTR, ROPSTR) -#define SLOT2(FUNCNAME, OPSTR, ARG1TYPE, ARG2TYPE, ARGCODES) \ -static PyObject * \ -FUNCNAME(PyObject *self, ARG1TYPE arg1, ARG2TYPE arg2) \ -{ \ - _Py_static_string(id, #OPSTR); \ - return call_method(self, &id, "(" ARGCODES ")", arg1, arg2); \ -} static Py_ssize_t slot_sq_length(PyObject *self) { - PyObject *res = call_method(self, &PyId___len__, "()"); + PyObject *res; Py_ssize_t len; - if (res == NULL) + res = call_method_noarg(self, &PyId___len__); + if (res == NULL) { return -1; + } + len = PyNumber_AsSsize_t(res, PyExc_OverflowError); Py_DECREF(res); if (len < 0) { @@ -5757,7 +6257,7 @@ slot_sq_length(PyObject *self) static PyObject * slot_sq_item(PyObject *self, Py_ssize_t i) { - PyObject *func, *args = NULL, *ival = NULL, *retval = NULL; + PyObject *func, *ival = NULL, *retval = NULL; descrgetfunc f; func = _PyType_LookupId(Py_TYPE(self), &PyId___getitem__); @@ -5772,21 +6272,16 @@ slot_sq_item(PyObject *self, Py_ssize_t } ival = PyLong_FromSsize_t(i); if (ival != NULL) { - args = PyTuple_New(1); - if (args != NULL) { - PyTuple_SET_ITEM(args, 0, ival); - retval = PyObject_Call(func, args, NULL); - Py_XDECREF(args); - Py_XDECREF(func); - return retval; - } + retval = PyObject_CallArg1(func, ival); + Py_XDECREF(func); + Py_DECREF(ival); + return retval; } } else { PyObject *getitem_str = _PyUnicode_FromId(&PyId___getitem__); PyErr_SetObject(PyExc_AttributeError, getitem_str); } - Py_XDECREF(args); Py_XDECREF(ival); Py_XDECREF(func); return NULL; @@ -5796,11 +6291,20 @@ static int slot_sq_ass_item(PyObject *self, Py_ssize_t index, PyObject *value) { PyObject *res; - - if (value == NULL) - res = call_method(self, &PyId___delitem__, "(n)", index); - else - res = call_method(self, &PyId___setitem__, "(nO)", index, value); + PyObject *index_obj; + + index_obj = PyLong_FromSize_t(index); + if (index_obj == NULL) { + return -1; + } + + if (value == NULL) { + res = call_method_arg1(self, &PyId___delitem__, index_obj); + } + else { + res = call_method_arg2(self, &PyId___setitem__, index_obj, value); + } + Py_DECREF(index_obj); if (res == NULL) return -1; Py_DECREF(res); @@ -5810,19 +6314,13 @@ slot_sq_ass_item(PyObject *self, Py_ssiz static int slot_sq_contains(PyObject *self, PyObject *value) { - PyObject *func, *res, *args; + PyObject *func, *res; int result = -1; _Py_IDENTIFIER(__contains__); func = lookup_maybe(self, &PyId___contains__); if (func != NULL) { - args = PyTuple_Pack(1, value); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } + res = PyObject_CallArg1(func, value); Py_DECREF(func); if (res != NULL) { result = PyObject_IsTrue(res); @@ -5839,17 +6337,19 @@ slot_sq_contains(PyObject *self, PyObjec #define slot_mp_length slot_sq_length -SLOT1(slot_mp_subscript, "__getitem__", PyObject *, "O") +SLOT1(slot_mp_subscript, "__getitem__", PyObject *) static int slot_mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value) { PyObject *res; - if (value == NULL) - res = call_method(self, &PyId___delitem__, "(O)", key); - else - res = call_method(self, &PyId___setitem__, "(OO)", key, value); + if (value == NULL) { + res = call_method_arg1(self, &PyId___delitem__, key); + } + else { + res = call_method_arg2(self, &PyId___setitem__, key, value); + } if (res == NULL) return -1; @@ -5880,8 +6380,9 @@ slot_nb_power(PyObject *self, PyObject * can call this when the second argument's type uses slot_nb_power, so check before calling self.__pow__. */ if (Py_TYPE(self)->tp_as_number != NULL && - Py_TYPE(self)->tp_as_number->nb_power == slot_nb_power) { - return call_method(self, &PyId___pow__, "(OO)", other, modulus); + Py_TYPE(self)->tp_as_number->nb_power == slot_nb_power) + { + return call_method_arg2(self, &PyId___pow__, other, modulus); } Py_RETURN_NOTIMPLEMENTED; } @@ -5893,7 +6394,7 @@ SLOT0(slot_nb_absolute, "__abs__") static int slot_nb_bool(PyObject *self) { - PyObject *func, *args; + PyObject *func, *temp; int result = -1; int using_len = 0; _Py_IDENTIFIER(__bool__); @@ -5902,33 +6403,36 @@ slot_nb_bool(PyObject *self) if (func == NULL) { if (PyErr_Occurred()) return -1; + func = lookup_maybe(self, &PyId___len__); - if (func == NULL) + if (func == NULL) { return PyErr_Occurred() ? -1 : 1; + } using_len = 1; } - args = PyTuple_New(0); - if (args != NULL) { - PyObject *temp = PyObject_Call(func, args, NULL); - Py_DECREF(args); - if (temp != NULL) { - if (using_len) { - /* enforced by slot_nb_len */ - result = PyObject_IsTrue(temp); - } - else if (PyBool_Check(temp)) { - result = PyObject_IsTrue(temp); - } - else { - PyErr_Format(PyExc_TypeError, - "__bool__ should return " - "bool, returned %s", - Py_TYPE(temp)->tp_name); - result = -1; - } - Py_DECREF(temp); - } - } + + temp = PyObject_CallNoArg(func); + if (temp == NULL) { + Py_DECREF(func); + return -1; + } + + if (using_len) { + /* enforced by slot_nb_len */ + result = PyObject_IsTrue(temp); + } + else if (PyBool_Check(temp)) { + result = PyObject_IsTrue(temp); + } + else { + PyErr_Format(PyExc_TypeError, + "__bool__ should return " + "bool, returned %s", + Py_TYPE(temp)->tp_name); + result = -1; + } + Py_DECREF(temp); + Py_DECREF(func); return result; } @@ -5938,7 +6442,8 @@ static PyObject * slot_nb_index(PyObject *self) { _Py_IDENTIFIER(__index__); - return call_method(self, &PyId___index__, "()"); + + return call_method_noarg(self, &PyId___index__); } @@ -5951,28 +6456,28 @@ SLOT1BIN(slot_nb_or, nb_or, "__or__", "_ SLOT0(slot_nb_int, "__int__") SLOT0(slot_nb_float, "__float__") -SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") -SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O") -SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *, "O") -SLOT1(slot_nb_inplace_matrix_multiply, "__imatmul__", PyObject *, "O") -SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *, "O") +SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *) +SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *) +SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *) +SLOT1(slot_nb_inplace_matrix_multiply, "__imatmul__", PyObject *) +SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *) /* Can't use SLOT1 here, because nb_inplace_power is ternary */ static PyObject * slot_nb_inplace_power(PyObject *self, PyObject * arg1, PyObject *arg2) { _Py_IDENTIFIER(__ipow__); - return call_method(self, &PyId___ipow__, "(" "O" ")", arg1); -} -SLOT1(slot_nb_inplace_lshift, "__ilshift__", PyObject *, "O") -SLOT1(slot_nb_inplace_rshift, "__irshift__", PyObject *, "O") -SLOT1(slot_nb_inplace_and, "__iand__", PyObject *, "O") -SLOT1(slot_nb_inplace_xor, "__ixor__", PyObject *, "O") -SLOT1(slot_nb_inplace_or, "__ior__", PyObject *, "O") + return call_method_arg1(self, &PyId___ipow__, arg1); +} +SLOT1(slot_nb_inplace_lshift, "__ilshift__", PyObject *) +SLOT1(slot_nb_inplace_rshift, "__irshift__", PyObject *) +SLOT1(slot_nb_inplace_and, "__iand__", PyObject *) +SLOT1(slot_nb_inplace_xor, "__ixor__", PyObject *) +SLOT1(slot_nb_inplace_or, "__ior__", PyObject *) SLOT1BIN(slot_nb_floor_divide, nb_floor_divide, "__floordiv__", "__rfloordiv__") SLOT1BIN(slot_nb_true_divide, nb_true_divide, "__truediv__", "__rtruediv__") -SLOT1(slot_nb_inplace_floor_divide, "__ifloordiv__", PyObject *, "O") -SLOT1(slot_nb_inplace_true_divide, "__itruediv__", PyObject *, "O") +SLOT1(slot_nb_inplace_floor_divide, "__ifloordiv__", PyObject *) +SLOT1(slot_nb_inplace_true_divide, "__itruediv__", PyObject *) static PyObject * slot_tp_repr(PyObject *self) @@ -5982,7 +6487,7 @@ slot_tp_repr(PyObject *self) func = lookup_method(self, &PyId___repr__); if (func != NULL) { - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); return res; } @@ -6000,7 +6505,7 @@ slot_tp_str(PyObject *self) func = lookup_method(self, &PyId___str__); if (func == NULL) return NULL; - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); return res; } @@ -6022,7 +6527,7 @@ slot_tp_hash(PyObject *self) return PyObject_HashNotImplemented(self); } - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); if (res == NULL) return -1; @@ -6053,7 +6558,7 @@ slot_tp_hash(PyObject *self) } static PyObject * -slot_tp_call(PyObject *self, PyObject *args, PyObject *kwds) +slot_tp_fastcall(PyObject *self, PyObject **stack, int na, PyObject *kwargs) { _Py_IDENTIFIER(__call__); PyObject *meth = lookup_method(self, &PyId___call__); @@ -6062,6 +6567,22 @@ slot_tp_call(PyObject *self, PyObject *a if (meth == NULL) return NULL; + res = _PyObject_FastCall(meth, stack, na, kwargs); + + Py_DECREF(meth); + return res; +} + +static PyObject * +slot_tp_call(PyObject *self, PyObject *args, PyObject *kwds) +{ + _Py_IDENTIFIER(__call__); + PyObject *meth = lookup_method(self, &PyId___call__); + PyObject *res; + + if (meth == NULL) + return NULL; + res = PyObject_Call(meth, args, kwds); Py_DECREF(meth); @@ -6082,7 +6603,7 @@ slot_tp_call(PyObject *self, PyObject *a static PyObject * slot_tp_getattro(PyObject *self, PyObject *name) { - return call_method(self, &PyId___getattribute__, "(O)", name); + return call_method_arg1(self, &PyId___getattribute__, name); } static PyObject * @@ -6098,7 +6619,7 @@ call_attribute(PyObject *self, PyObject else attr = descr; } - res = PyObject_CallFunctionObjArgs(attr, name, NULL); + res = PyObject_CallArg1(attr, name); Py_XDECREF(descr); return res; } @@ -6154,9 +6675,9 @@ slot_tp_setattro(PyObject *self, PyObjec _Py_IDENTIFIER(__setattr__); if (value == NULL) - res = call_method(self, &PyId___delattr__, "(O)", name); + res = call_method_arg1(self, &PyId___delattr__, name); else - res = call_method(self, &PyId___setattr__, "(OO)", name, value); + res = call_method_arg2(self, &PyId___setattr__, name, value); if (res == NULL) return -1; Py_DECREF(res); @@ -6175,20 +6696,14 @@ static _Py_Identifier name_op[] = { static PyObject * slot_tp_richcompare(PyObject *self, PyObject *other, int op) { - PyObject *func, *args, *res; + PyObject *func, *res; func = lookup_method(self, &name_op[op]); if (func == NULL) { PyErr_Clear(); Py_RETURN_NOTIMPLEMENTED; } - args = PyTuple_Pack(1, other); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } + res = PyObject_CallArg1(func, other); Py_DECREF(func); return res; } @@ -6201,12 +6716,7 @@ slot_tp_iter(PyObject *self) func = lookup_method(self, &PyId___iter__); if (func != NULL) { - PyObject *args; - args = res = PyTuple_New(0); - if (args != NULL) { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } + res = PyObject_CallNoArg(func); Py_DECREF(func); return res; } @@ -6226,7 +6736,7 @@ static PyObject * slot_tp_iternext(PyObject *self) { _Py_IDENTIFIER(__next__); - return call_method(self, &PyId___next__, "()"); + return call_method_noarg(self, &PyId___next__); } static PyObject * @@ -6259,9 +6769,9 @@ slot_tp_descr_set(PyObject *self, PyObje _Py_IDENTIFIER(__set__); if (value == NULL) - res = call_method(self, &PyId___delete__, "(O)", target); + res = call_method_arg1(self, &PyId___delete__, target); else - res = call_method(self, &PyId___set__, "(OO)", target, value); + res = call_method_arg2(self, &PyId___set__, target, value); if (res == NULL) return -1; Py_DECREF(res); @@ -6292,6 +6802,57 @@ slot_tp_init(PyObject *self, PyObject *a return 0; } +static int +slot_tp_fastinit(PyObject *self, PyObject **stack, int na, PyObject *kwargs) +{ + _Py_IDENTIFIER(__init__); + PyObject *meth = lookup_method(self, &PyId___init__); + PyObject *res; + + if (meth == NULL) + return -1; + res = _PyObject_FastCall(meth, stack, na, kwargs); + Py_DECREF(meth); + if (res == NULL) + return -1; + if (res != Py_None) { + PyErr_Format(PyExc_TypeError, + "__init__() should return None, not '%.200s'", + Py_TYPE(res)->tp_name); + Py_DECREF(res); + return -1; + } + Py_DECREF(res); + return 0; +} + +static PyObject * +slot_tp_fastnew(PyTypeObject *type, PyObject **stack, int na, PyObject *kwargs) +{ + PyObject* small_stack[_PyStack_SIZE]; + PyObject **stack2; + PyObject *func; + PyObject *result; + + func = _PyObject_GetAttrId((PyObject *)type, &PyId___new__); + if (func == NULL) { + return NULL; + } + + stack2 = _PyStack_PrependArg(stack, na, small_stack, Py_ARRAY_LENGTH(small_stack), + (PyObject *)type); + if (stack2 == NULL) { + Py_DECREF(func); + return NULL; + } + + result = _PyObject_FastCall((PyObject *)func, stack2, 1 + na, kwargs); + _PyStack_Free(stack2, small_stack, 1 + na); + Py_DECREF(func); + return result; +} + +/* FIXME: remove slot_tp_new, always use slot_tp_fastnew */ static PyObject * slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -6333,7 +6894,7 @@ slot_tp_finalize(PyObject *self) /* Execute __del__ method, if any. */ del = lookup_maybe(self, &PyId___del__); if (del != NULL) { - res = PyEval_CallObject(del, NULL); + res = PyObject_CallNoArg(del); if (res == NULL) PyErr_WriteUnraisable(del); else @@ -6353,7 +6914,7 @@ slot_am_await(PyObject *self) func = lookup_method(self, &PyId___await__); if (func != NULL) { - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); return res; } @@ -6371,7 +6932,7 @@ slot_am_aiter(PyObject *self) func = lookup_method(self, &PyId___aiter__); if (func != NULL) { - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); return res; } @@ -6389,7 +6950,7 @@ slot_am_anext(PyObject *self) func = lookup_method(self, &PyId___anext__); if (func != NULL) { - res = PyEval_CallObject(func, NULL); + res = PyObject_CallNoArg(func); Py_DECREF(func); return res; } @@ -6427,28 +6988,35 @@ typedef struct wrapperbase slotdef; #define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ PyDoc_STR(DOC)} +#define TPSLOT_FAST(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ + PyDoc_STR(DOC), 0, NULL, FAST_WRAPPER} #define FLSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, FLAGS) \ {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ PyDoc_STR(DOC), FLAGS} #define ETSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ {NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ - PyDoc_STR(DOC)} -#define AMSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_async.SLOT, FUNCTION, WRAPPER, DOC) -#define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, DOC) -#define MPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_mapping.SLOT, FUNCTION, WRAPPER, DOC) -#define NBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, DOC) -#define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \ + PyDoc_STR(DOC), 0, NULL, NULL} +#define ETSLOT_FAST(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + {NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ + PyDoc_STR(DOC), 0, NULL, FAST_WRAPPER} +#define AMSLOT(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + ETSLOT_FAST(NAME, as_async.SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) +#define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + ETSLOT_FAST(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) +#define MPSLOT(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + ETSLOT_FAST(NAME, as_mapping.SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) +#define NBSLOT(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + ETSLOT_FAST(NAME, as_number.SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) +#define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + ETSLOT_FAST(NAME, as_number.SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, \ NAME "($self, /)\n--\n\n" DOC) -#define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \ +#define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, DOC) \ + ETSLOT_FAST(NAME, as_number.SLOT, FUNCTION, WRAPPER, FAST_WRAPPER, \ NAME "($self, value, /)\n--\n\nReturn self" DOC "value.") #define BINSLOT(NAME, SLOT, FUNCTION, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \ + ETSLOT_FAST(NAME, as_number.SLOT, FUNCTION, \ + wrap_binaryfunc_l, wrap_fast_binaryfunc_l, \ NAME "($self, value, /)\n--\n\nReturn self" DOC "value.") #define RBINSLOT(NAME, SLOT, FUNCTION, DOC) \ ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \ @@ -6465,22 +7033,22 @@ static slotdef slotdefs[] = { TPSLOT("__getattr__", tp_getattr, NULL, NULL, ""), TPSLOT("__setattr__", tp_setattr, NULL, NULL, ""), TPSLOT("__delattr__", tp_setattr, NULL, NULL, ""), - TPSLOT("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc, + TPSLOT_FAST("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc, wrap_fast_unaryfunc, "__repr__($self, /)\n--\n\nReturn repr(self)."), - TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, + TPSLOT_FAST("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, wrap_fast_hashfunc, "__hash__($self, /)\n--\n\nReturn hash(self)."), FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, "__call__($self, /, *args, **kwargs)\n--\n\nCall self as a function.", - PyWrapperFlag_KEYWORDS), - TPSLOT("__str__", tp_str, slot_tp_str, wrap_unaryfunc, + PyWrapperFlag_FASTWRAPPER), + TPSLOT_FAST("__str__", tp_str, slot_tp_str, wrap_unaryfunc, wrap_fast_unaryfunc, "__str__($self, /)\n--\n\nReturn str(self)."), - TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook, - wrap_binaryfunc, + TPSLOT_FAST("__getattribute__", tp_getattro, slot_tp_getattr_hook, + wrap_binaryfunc, wrap_fast_binaryfunc, "__getattribute__($self, name, /)\n--\n\nReturn getattr(self, name)."), TPSLOT("__getattr__", tp_getattro, slot_tp_getattr_hook, NULL, ""), - TPSLOT("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr, + TPSLOT_FAST("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr, wrap_fast_setattr, "__setattr__($self, name, value, /)\n--\n\nImplement setattr(self, name, value)."), - TPSLOT("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr, + TPSLOT_FAST("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr, wrap_fast_delattr, "__delattr__($self, name, /)\n--\n\nImplement delattr(self, name)."), TPSLOT("__lt__", tp_richcompare, slot_tp_richcompare, richcmp_lt, "__lt__($self, value, /)\n--\n\nReturn selfvalue."), TPSLOT("__ge__", tp_richcompare, slot_tp_richcompare, richcmp_ge, "__ge__($self, value, /)\n--\n\nReturn self>=value."), - TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, + TPSLOT_FAST("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, wrap_fast_unaryfunc, "__iter__($self, /)\n--\n\nImplement iter(self)."), - TPSLOT("__next__", tp_iternext, slot_tp_iternext, wrap_next, + TPSLOT_FAST("__next__", tp_iternext, slot_tp_iternext, wrap_next, wrap_fast_next, "__next__($self, /)\n--\n\nImplement next(self)."), - TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get, + TPSLOT_FAST("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get, wrap_descr_fastget, "__get__($self, instance, owner, /)\n--\n\nReturn an attribute of instance, which is of type owner."), - TPSLOT("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set, + TPSLOT_FAST("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set, wrap_descr_fastset, "__set__($self, instance, value, /)\n--\n\nSet an attribute of instance to value."), - TPSLOT("__delete__", tp_descr_set, slot_tp_descr_set, - wrap_descr_delete, + TPSLOT_FAST("__delete__", tp_descr_set, slot_tp_descr_set, + wrap_descr_delete, wrap_descr_fastdelete, "__delete__($self, instance, /)\n--\n\nDelete an attribute of instance."), FLSLOT("__init__", tp_init, slot_tp_init, (wrapperfunc)wrap_init, "__init__($self, /, *args, **kwargs)\n--\n\n" "Initialize self. See help(type(self)) for accurate signature.", - PyWrapperFlag_KEYWORDS), + PyWrapperFlag_FASTWRAPPER), TPSLOT("__new__", tp_new, slot_tp_new, NULL, "__new__(type, /, *args, **kwargs)\n--\n\n" "Create and return new object. See help(type) for accurate signature."), TPSLOT("__del__", tp_finalize, slot_tp_finalize, (wrapperfunc)wrap_del, ""), - AMSLOT("__await__", am_await, slot_am_await, wrap_unaryfunc, + AMSLOT("__await__", am_await, slot_am_await, wrap_unaryfunc, wrap_fast_unaryfunc, "__await__($self, /)\n--\n\nReturn an iterator to be used in await expression."), - AMSLOT("__aiter__", am_aiter, slot_am_aiter, wrap_unaryfunc, + AMSLOT("__aiter__", am_aiter, slot_am_aiter, wrap_unaryfunc, wrap_fast_unaryfunc, "__aiter__($self, /)\n--\n\nReturn an awaitable, that resolves in asynchronous iterator."), - AMSLOT("__anext__", am_anext, slot_am_anext, wrap_unaryfunc, + AMSLOT("__anext__", am_anext, slot_am_anext, wrap_unaryfunc, wrap_fast_unaryfunc, "__anext__($self, /)\n--\n\nReturn a value or raise StopAsyncIteration."), BINSLOT("__add__", nb_add, slot_nb_add, @@ -6541,17 +7109,17 @@ static slotdef slotdefs[] = { "Return divmod(self, value)."), RBINSLOTNOTINFIX("__rdivmod__", nb_divmod, slot_nb_divmod, "Return divmod(value, self)."), - NBSLOT("__pow__", nb_power, slot_nb_power, wrap_ternaryfunc, + NBSLOT("__pow__", nb_power, slot_nb_power, wrap_pow, wrap_fast_pow, "__pow__($self, value, mod=None, /)\n--\n\nReturn pow(self, value, mod)."), - NBSLOT("__rpow__", nb_power, slot_nb_power, wrap_ternaryfunc_r, + NBSLOT("__rpow__", nb_power, slot_nb_power, wrap_rpow, wrap_fast_rpow, "__rpow__($self, value, mod=None, /)\n--\n\nReturn pow(value, self, mod)."), - UNSLOT("__neg__", nb_negative, slot_nb_negative, wrap_unaryfunc, "-self"), - UNSLOT("__pos__", nb_positive, slot_nb_positive, wrap_unaryfunc, "+self"), - UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, + UNSLOT("__neg__", nb_negative, slot_nb_negative, wrap_unaryfunc, wrap_fast_unaryfunc, "-self"), + UNSLOT("__pos__", nb_positive, slot_nb_positive, wrap_unaryfunc, wrap_fast_unaryfunc, "+self"), + UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, wrap_fast_unaryfunc, "abs(self)"), - UNSLOT("__bool__", nb_bool, slot_nb_bool, wrap_inquirypred, + UNSLOT("__bool__", nb_bool, slot_nb_bool, wrap_inquirypred, wrap_fast_inquirypred, "self != 0"), - UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~self"), + UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, wrap_fast_unaryfunc, "~self"), BINSLOT("__lshift__", nb_lshift, slot_nb_lshift, "<<"), RBINSLOT("__rlshift__", nb_lshift, slot_nb_lshift, "<<"), BINSLOT("__rshift__", nb_rshift, slot_nb_rshift, ">>"), @@ -6562,39 +7130,39 @@ static slotdef slotdefs[] = { RBINSLOT("__rxor__", nb_xor, slot_nb_xor, "^"), BINSLOT("__or__", nb_or, slot_nb_or, "|"), RBINSLOT("__ror__", nb_or, slot_nb_or, "|"), - UNSLOT("__int__", nb_int, slot_nb_int, wrap_unaryfunc, + UNSLOT("__int__", nb_int, slot_nb_int, wrap_unaryfunc, wrap_fast_unaryfunc, "int(self)"), - UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, + UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, wrap_fast_unaryfunc, "float(self)"), IBSLOT("__iadd__", nb_inplace_add, slot_nb_inplace_add, - wrap_binaryfunc, "+="), + wrap_binaryfunc, wrap_fast_binaryfunc,"+="), IBSLOT("__isub__", nb_inplace_subtract, slot_nb_inplace_subtract, - wrap_binaryfunc, "-="), + wrap_binaryfunc, wrap_fast_binaryfunc,"-="), IBSLOT("__imul__", nb_inplace_multiply, slot_nb_inplace_multiply, - wrap_binaryfunc, "*="), + wrap_binaryfunc, wrap_fast_binaryfunc,"*="), IBSLOT("__imod__", nb_inplace_remainder, slot_nb_inplace_remainder, - wrap_binaryfunc, "%="), + wrap_binaryfunc, wrap_fast_binaryfunc,"%="), IBSLOT("__ipow__", nb_inplace_power, slot_nb_inplace_power, - wrap_binaryfunc, "**="), + wrap_binaryfunc, wrap_fast_binaryfunc,"**="), IBSLOT("__ilshift__", nb_inplace_lshift, slot_nb_inplace_lshift, - wrap_binaryfunc, "<<="), + wrap_binaryfunc, wrap_fast_binaryfunc,"<<="), IBSLOT("__irshift__", nb_inplace_rshift, slot_nb_inplace_rshift, - wrap_binaryfunc, ">>="), + wrap_binaryfunc, wrap_fast_binaryfunc,">>="), IBSLOT("__iand__", nb_inplace_and, slot_nb_inplace_and, - wrap_binaryfunc, "&="), + wrap_binaryfunc, wrap_fast_binaryfunc,"&="), IBSLOT("__ixor__", nb_inplace_xor, slot_nb_inplace_xor, - wrap_binaryfunc, "^="), + wrap_binaryfunc, wrap_fast_binaryfunc,"^="), IBSLOT("__ior__", nb_inplace_or, slot_nb_inplace_or, - wrap_binaryfunc, "|="), + wrap_binaryfunc, wrap_fast_binaryfunc,"|="), BINSLOT("__floordiv__", nb_floor_divide, slot_nb_floor_divide, "//"), RBINSLOT("__rfloordiv__", nb_floor_divide, slot_nb_floor_divide, "//"), BINSLOT("__truediv__", nb_true_divide, slot_nb_true_divide, "/"), RBINSLOT("__rtruediv__", nb_true_divide, slot_nb_true_divide, "/"), IBSLOT("__ifloordiv__", nb_inplace_floor_divide, - slot_nb_inplace_floor_divide, wrap_binaryfunc, "//="), + slot_nb_inplace_floor_divide, wrap_binaryfunc, wrap_fast_binaryfunc,"//="), IBSLOT("__itruediv__", nb_inplace_true_divide, - slot_nb_inplace_true_divide, wrap_binaryfunc, "/="), - NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, + slot_nb_inplace_true_divide, wrap_binaryfunc, wrap_fast_binaryfunc,"/="), + NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, wrap_fast_unaryfunc, "__index__($self, /)\n--\n\n" "Return self converted to an integer, if self is suitable " "for use as an index into a list."), @@ -6603,45 +7171,45 @@ static slotdef slotdefs[] = { RBINSLOT("__rmatmul__", nb_matrix_multiply, slot_nb_matrix_multiply, "@"), IBSLOT("__imatmul__", nb_inplace_matrix_multiply, slot_nb_inplace_matrix_multiply, - wrap_binaryfunc, "@="), - MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc, + wrap_binaryfunc, wrap_fast_binaryfunc,"@="), + MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc, wrap_fast_lenfunc, "__len__($self, /)\n--\n\nReturn len(self)."), MPSLOT("__getitem__", mp_subscript, slot_mp_subscript, - wrap_binaryfunc, + wrap_binaryfunc, wrap_fast_binaryfunc, "__getitem__($self, key, /)\n--\n\nReturn self[key]."), MPSLOT("__setitem__", mp_ass_subscript, slot_mp_ass_subscript, - wrap_objobjargproc, + wrap_objobjargproc, wrap_fast_objobjargproc, "__setitem__($self, key, value, /)\n--\n\nSet self[key] to value."), MPSLOT("__delitem__", mp_ass_subscript, slot_mp_ass_subscript, - wrap_delitem, + wrap_delitem, wrap_fast_delitem, "__delitem__($self, key, /)\n--\n\nDelete self[key]."), - SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc, + SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc, wrap_fast_lenfunc, "__len__($self, /)\n--\n\nReturn len(self)."), /* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL. The logic in abstract.c always falls back to nb_add/nb_multiply in this case. Defining both the nb_* and the sq_* slots to call the user-defined methods has unexpected side-effects, as shown by test_descr.notimplemented() */ - SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc, + SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc, wrap_fast_binaryfunc, "__add__($self, value, /)\n--\n\nReturn self+value."), - SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc, + SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc, wrap_fast_indexargfunc, "__mul__($self, value, /)\n--\n\nReturn self*value.n"), - SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc, + SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc, wrap_fast_indexargfunc, "__rmul__($self, value, /)\n--\n\nReturn self*value."), - SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, + SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, wrap_fast_sq_item, "__getitem__($self, key, /)\n--\n\nReturn self[key]."), - SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, + SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, wrap_fast_sq_setitem, "__setitem__($self, key, value, /)\n--\n\nSet self[key] to value."), - SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, + SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, wrap_fast_sq_delitem, "__delitem__($self, key, /)\n--\n\nDelete self[key]."), - SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, + SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, wrap_fast_objobjproc, "__contains__($self, key, /)\n--\n\nReturn key in self."), SQSLOT("__iadd__", sq_inplace_concat, NULL, - wrap_binaryfunc, + wrap_binaryfunc, wrap_fast_binaryfunc, "__iadd__($self, value, /)\n--\n\nImplement self+=value."), SQSLOT("__imul__", sq_inplace_repeat, NULL, - wrap_indexargfunc, + wrap_indexargfunc, wrap_fast_indexargfunc, "__imul__($self, value, /)\n--\n\nImplement self*=value."), {NULL} @@ -6744,6 +7312,13 @@ update_one_slot(PyTypeObject *type, slot int use_generic = 0; int offset = p->offset; void **ptr = slotptr(type, offset); + /* FIXME: simplify code to decide if FAST bits must be cleared */ + int generic_fastnew = -1; + int specific_fastnew = -1; + int generic_fastinit = -1; + int specific_fastinit = -1; + int generic_fastcall = -1; + int specific_fastcall = -1; if (ptr == NULL) { do { @@ -6756,23 +7331,53 @@ update_one_slot(PyTypeObject *type, slot if (descr == NULL) { if (ptr == (void**)&type->tp_iternext) { specific = (void *)_PyObject_NextNotImplemented; + specific_fastnew = -1; + specific_fastinit = -1; + specific_fastcall = -1; } continue; } if (Py_TYPE(descr) == &PyWrapperDescr_Type && ((PyWrapperDescrObject *)descr)->d_base->name_strobj == p->name_strobj) { void **tptr = resolve_slotdups(type, p->name_strobj); - if (tptr == NULL || tptr == ptr) + if (tptr == NULL || tptr == ptr) { generic = p->function; + generic_fastnew = -1; + generic_fastinit = -1; + generic_fastcall = -1; + if (strcmp(p->name, "__new__") == 0) { + generic_fastnew = 0; + } + if (strcmp(p->name, "__init__") == 0) { + generic_fastinit = 0; + } + if (strcmp(p->name, "__call__") == 0) { + generic_fastcall = 0; + } + } d = (PyWrapperDescrObject *)descr; if (d->d_base->wrapper == p->wrapper && PyType_IsSubtype(type, PyDescr_TYPE(d))) { if (specific == NULL || - specific == d->d_wrapped) + specific == d->d_wrapped) { specific = d->d_wrapped; - else + specific_fastnew = -1; + specific_fastinit = -1; + specific_fastcall = -1; + if (strcmp(p->name, "__new__") == 0) { + specific_fastnew = 0; + } + if (strcmp(p->name, "__init__") == 0) { + specific_fastinit = !!(d->d_type_flags & Py_TPFLAGS_FASTINIT); + } + if (strcmp(p->name, "__call__") == 0) { + specific_fastcall = !!(d->d_type_flags & Py_TPFLAGS_FASTCALL); + } + } + else { use_generic = 1; + } } } else if (Py_TYPE(descr) == &PyCFunction_Type && @@ -6780,6 +7385,7 @@ update_one_slot(PyTypeObject *type, slot (PyCFunction)tp_new_wrapper && ptr == (void**)&type->tp_new) { + PyTypeObject *self = ((PyTypeObject *)PyCFunction_GET_SELF(descr)); /* The __new__ wrapper is not a wrapper descriptor, so must be special-cased differently. If we don't do this, creating an instance will @@ -6791,7 +7397,10 @@ update_one_slot(PyTypeObject *type, slot sanity checks and constructing a new argument list. Cut all that nonsense short -- this speeds up instance creation tremendously. */ - specific = (void *)((PyTypeObject *)PyCFunction_GET_SELF(descr))->tp_new; + specific = (void *)self->tp_new; + specific_fastnew = (self->tp_flags & Py_TPFLAGS_FASTNEW); + specific_fastinit = -1; + specific_fastcall = -1; /* XXX I'm not 100% sure that there isn't a hole in this reasoning that requires additional sanity checks. I'll buy the first person to @@ -6803,16 +7412,69 @@ update_one_slot(PyTypeObject *type, slot to prevent inheritance of the default implementation from object.__hash__ */ specific = (void *)PyObject_HashNotImplemented; + specific_fastnew = -1; + specific_fastinit = -1; + specific_fastcall = -1; } else { use_generic = 1; generic = p->function; + generic_fastnew = -1; + generic_fastinit = -1; + generic_fastcall = -1; + if (strcmp(p->name, "__new__") == 0) { + generic_fastnew = 0; + } + if (strcmp(p->name, "__init__") == 0) { + generic_fastinit = 0; + } + if (strcmp(p->name, "__call__") == 0) { + generic_fastcall = 0; + } } } while ((++p)->offset == offset); - if (specific && !use_generic) + if (specific && !use_generic) { *ptr = specific; - else + if (specific_fastnew == 1) { + type->tp_flags |= Py_TPFLAGS_FASTNEW; + } + else if (specific_fastnew == 0) { + type->tp_flags &= ~Py_TPFLAGS_FASTNEW; + } + if (specific_fastinit == 1) { + type->tp_flags |= Py_TPFLAGS_FASTINIT; + } + else if (specific_fastinit == 0) { + type->tp_flags &= ~Py_TPFLAGS_FASTINIT; + } + if (specific_fastcall == 1) { + type->tp_flags |= Py_TPFLAGS_FASTCALL; + } + else if (specific_fastcall == 0) { + type->tp_flags &= ~Py_TPFLAGS_FASTCALL; + } + } + else { *ptr = generic; + if (generic_fastnew == 1) { + type->tp_flags |= Py_TPFLAGS_FASTNEW; + } + else if (generic_fastnew == 0) { + type->tp_flags &= ~Py_TPFLAGS_FASTNEW; + } + if (generic_fastinit == 1) { + type->tp_flags |= Py_TPFLAGS_FASTINIT; + } + else if (generic_fastinit == 0) { + type->tp_flags &= ~Py_TPFLAGS_FASTINIT; + } + if (generic_fastcall == 1) { + type->tp_flags |= Py_TPFLAGS_FASTCALL; + } + else if (generic_fastcall == 0) { + type->tp_flags &= ~Py_TPFLAGS_FASTCALL; + } + } return p; } @@ -6895,6 +7557,29 @@ update_slot(PyTypeObject *type, PyObject update_slots_callback, (void *)ptrs); } +static void +fixup_fast_slots(PyTypeObject *type) +{ + if (type->tp_new == slot_tp_new) { + type->tp_new = (newfunc)slot_tp_fastnew; + type->tp_flags |= Py_TPFLAGS_FASTNEW; + } + else if (type->tp_new == PyType_GenericNew) { + type->tp_new = (newfunc)_PyType_FastGenericNew; + type->tp_flags |= Py_TPFLAGS_FASTNEW; + } + + if (type->tp_init == slot_tp_init) { + type->tp_init = (initproc)slot_tp_fastinit; + type->tp_flags |= Py_TPFLAGS_FASTINIT; + } + + if (type->tp_call == slot_tp_call) { + type->tp_call = (ternaryfunc)slot_tp_fastcall; + type->tp_flags |= Py_TPFLAGS_FASTCALL; + } +} + /* Store the proper functions in the slot dispatches at class (type) definition time, based upon which operations the class overrides in its dict. */ @@ -6906,6 +7591,8 @@ fixup_slot_dispatchers(PyTypeObject *typ init_slotdefs(); for (p = slotdefs; p->name; ) p = update_one_slot(type, p); + + fixup_fast_slots(type); } static void @@ -7019,7 +7706,9 @@ add_operators(PyTypeObject *type) return -1; } else { - descr = PyDescr_NewWrapper(type, p, *ptr); + int flags = type->tp_flags; + + descr = _PyDescr_NewWrapperEx(type, p, *ptr, flags); if (descr == NULL) return -1; if (PyDict_SetItem(dict, p->name_strobj, descr) < 0) @@ -7234,8 +7923,8 @@ super_descr_get(PyObject *self, PyObject PyTypeObject *obj_type = supercheck(su->type, obj); if (obj_type == NULL) return NULL; - newobj = (superobject *)PySuper_Type.tp_new(&PySuper_Type, - NULL, NULL); + newobj = (superobject *)_PyType_CallNew(&PySuper_Type, &PySuper_Type, + NULL, NULL); if (newobj == NULL) return NULL; Py_INCREF(su->type); @@ -7248,7 +7937,7 @@ super_descr_get(PyObject *self, PyObject } static int -super_init(PyObject *self, PyObject *args, PyObject *kwds) +super_init(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { superobject *su = (superobject *)self; PyTypeObject *type = NULL; @@ -7257,7 +7946,7 @@ super_init(PyObject *self, PyObject *arg if (!_PyArg_NoKeywords("super", kwds)) return -1; - if (!PyArg_ParseTuple(args, "|O!O:super", &PyType_Type, &type, &obj)) + if (!PyArg_ParseStack(stack, nargs, "|O!O:super", &PyType_Type, &type, &obj)) return -1; if (type == NULL) { @@ -7404,8 +8093,8 @@ PyTypeObject PySuper_Type = { super_getattro, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC + | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_FASTINIT, /* tp_flags */ super_doc, /* tp_doc */ super_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -7421,7 +8110,7 @@ PyTypeObject PySuper_Type = { super_descr_get, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - super_init, /* tp_init */ + (initproc)super_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ PyType_GenericNew, /* tp_new */ PyObject_GC_Del, /* tp_free */ diff -r 496e094f4734 -r 34456cce64bb Objects/unicodeobject.c --- a/Objects/unicodeobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/unicodeobject.c Thu May 19 13:47:42 2016 +0200 @@ -12205,11 +12205,11 @@ do_strip(PyObject *self, int striptype) static PyObject * -do_argstrip(PyObject *self, int striptype, PyObject *args) +do_argstrip(PyObject *self, int striptype, PyObject **stack, int nargs) { PyObject *sep = NULL; - if (!PyArg_ParseTuple(args, stripformat[striptype], &sep)) + if (!PyArg_ParseStack(stack, nargs, stripformat[striptype], &sep)) return NULL; if (sep != NULL && sep != Py_None) { @@ -12235,12 +12235,12 @@ whitespace removed.\n\ If chars is given and not None, remove characters in chars instead."); static PyObject * -unicode_strip(PyObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) +unicode_strip(PyObject *self, PyObject **stack, int nargs) +{ + if (nargs == 0) return do_strip(self, BOTHSTRIP); /* Common case */ else - return do_argstrip(self, BOTHSTRIP, args); + return do_argstrip(self, BOTHSTRIP, stack, nargs); } @@ -12251,12 +12251,12 @@ Return a copy of the string S with leadi If chars is given and not None, remove characters in chars instead."); static PyObject * -unicode_lstrip(PyObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) +unicode_lstrip(PyObject *self, PyObject **stack, int nargs) +{ + if (nargs == 0) return do_strip(self, LEFTSTRIP); /* Common case */ else - return do_argstrip(self, LEFTSTRIP, args); + return do_argstrip(self, LEFTSTRIP, stack, nargs); } @@ -12267,12 +12267,12 @@ Return a copy of the string S with trail If chars is given and not None, remove characters in chars instead."); static PyObject * -unicode_rstrip(PyObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) +unicode_rstrip(PyObject *self, PyObject **stack, int nargs) +{ + if (nargs == 0) return do_strip(self, RIGHTSTRIP); /* Common case */ else - return do_argstrip(self, RIGHTSTRIP, args); + return do_argstrip(self, RIGHTSTRIP, stack, nargs); } @@ -12647,13 +12647,13 @@ whitespace string is a separator and emp removed from the result."); static PyObject* -unicode_split(PyObject *self, PyObject *args, PyObject *kwds) +unicode_split(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { static char *kwlist[] = {"sep", "maxsplit", 0}; PyObject *substring = Py_None; Py_ssize_t maxcount = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|On:split", + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|On:split", kwlist, &substring, &maxcount)) return NULL; @@ -13633,7 +13633,7 @@ unicode_getnewargs(PyObject *v) static PyMethodDef unicode_methods[] = { {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encode__doc__}, {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, - {"split", (PyCFunction) unicode_split, METH_VARARGS | METH_KEYWORDS, split__doc__}, + {"split", (PyCFunction) unicode_split, METH_FASTCALL, split__doc__}, {"rsplit", (PyCFunction) unicode_rsplit, METH_VARARGS | METH_KEYWORDS, rsplit__doc__}, {"join", (PyCFunction) unicode_join, METH_O, join__doc__}, {"capitalize", (PyCFunction) unicode_capitalize, METH_NOARGS, capitalize__doc__}, @@ -13648,15 +13648,15 @@ static PyMethodDef unicode_methods[] = { {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, - {"lstrip", (PyCFunction) unicode_lstrip, METH_VARARGS, lstrip__doc__}, + {"lstrip", (PyCFunction) unicode_lstrip, METH_FASTCALL, lstrip__doc__}, {"rfind", (PyCFunction) unicode_rfind, METH_VARARGS, rfind__doc__}, {"rindex", (PyCFunction) unicode_rindex, METH_VARARGS, rindex__doc__}, {"rjust", (PyCFunction) unicode_rjust, METH_VARARGS, rjust__doc__}, - {"rstrip", (PyCFunction) unicode_rstrip, METH_VARARGS, rstrip__doc__}, + {"rstrip", (PyCFunction) unicode_rstrip, METH_FASTCALL, rstrip__doc__}, {"rpartition", (PyCFunction) unicode_rpartition, METH_O, rpartition__doc__}, {"splitlines", (PyCFunction) unicode_splitlines, METH_VARARGS | METH_KEYWORDS, splitlines__doc__}, - {"strip", (PyCFunction) unicode_strip, METH_VARARGS, strip__doc__}, + {"strip", (PyCFunction) unicode_strip, METH_FASTCALL, strip__doc__}, {"swapcase", (PyCFunction) unicode_swapcase, METH_NOARGS, swapcase__doc__}, {"translate", (PyCFunction) unicode_translate, METH_O, translate__doc__}, {"upper", (PyCFunction) unicode_upper, METH_NOARGS, upper__doc__}, @@ -14750,10 +14750,10 @@ PyUnicode_Format(PyObject *format, PyObj } static PyObject * -unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +unicode_subtype_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds); static PyObject * -unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +unicode_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *x = NULL; static char *kwlist[] = {"object", "encoding", "errors", 0}; @@ -14761,8 +14761,8 @@ unicode_new(PyTypeObject *type, PyObject char *errors = NULL; if (type != &PyUnicode_Type) - return unicode_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:str", + return unicode_subtype_new(type, stack, nargs, kwds); + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "|Oss:str", kwlist, &x, &encoding, &errors)) return NULL; if (x == NULL) @@ -14774,7 +14774,7 @@ unicode_new(PyTypeObject *type, PyObject } static PyObject * -unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +unicode_subtype_new(PyTypeObject *type, PyObject **stack, int nargs, PyObject *kwds) { PyObject *unicode, *self; Py_ssize_t length, char_size; @@ -14784,7 +14784,7 @@ unicode_subtype_new(PyTypeObject *type, assert(PyType_IsSubtype(type, &PyUnicode_Type)); - unicode = unicode_new(&PyUnicode_Type, args, kwds); + unicode = unicode_new(&PyUnicode_Type, stack, nargs, kwds); if (unicode == NULL) return NULL; assert(_PyUnicode_CHECK(unicode)); @@ -14908,8 +14908,8 @@ PyTypeObject PyUnicode_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_UNICODE_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_UNICODE_SUBCLASS + | Py_TPFLAGS_FASTNEW, /* tp_flags */ unicode_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -14927,7 +14927,7 @@ PyTypeObject PyUnicode_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - unicode_new, /* tp_new */ + (newfunc)unicode_new, /* tp_new */ PyObject_Del, /* tp_free */ }; diff -r 496e094f4734 -r 34456cce64bb Objects/weakrefobject.c --- a/Objects/weakrefobject.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Objects/weakrefobject.c Thu May 19 13:47:42 2016 +0200 @@ -125,16 +125,18 @@ gc_clear(PyWeakReference *self) static PyObject * -weakref_call(PyWeakReference *self, PyObject *args, PyObject *kw) +weakref_call(PyWeakReference *self, PyObject **stack, int na, PyObject *kwargs) { - static char *kwlist[] = {NULL}; + PyObject *object; - if (PyArg_ParseTupleAndKeywords(args, kw, ":__call__", kwlist)) { - PyObject *object = PyWeakref_GET_OBJECT(self); - Py_INCREF(object); - return (object); + if (_PyStack_CheckArgs(stack, na, kwargs, "__call__", 0, 0) < 0) { + return NULL; } - return NULL; + + object = PyWeakref_GET_OBJECT(self); + + Py_INCREF(object); + return object; } @@ -365,7 +367,7 @@ PyTypeObject 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC - | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_FASTCALL, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ @@ -459,7 +461,7 @@ proxy_checkref(PyWeakReference *proxy) WRAP_BINARY(proxy_getattr, PyObject_GetAttr) WRAP_UNARY(proxy_str, PyObject_Str) -WRAP_TERNARY(proxy_call, PyEval_CallObjectWithKeywords) +WRAP_TERNARY(proxy_call, PyObject_Call) static PyObject * proxy_repr(PyWeakReference *proxy) @@ -865,7 +867,7 @@ PyWeakref_GetObject(PyObject *ref) static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); + PyObject *cbresult = PyObject_CallArg1(callback, (PyObject *)ref); if (cbresult == NULL) PyErr_WriteUnraisable(callback); diff -r 496e094f4734 -r 34456cce64bb PC/clinic/msvcrtmodule.c.h --- a/PC/clinic/msvcrtmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/PC/clinic/msvcrtmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -37,22 +37,24 @@ PyDoc_STRVAR(msvcrt_locking__doc__, "individually."); #define MSVCRT_LOCKING_METHODDEF \ - {"locking", (PyCFunction)msvcrt_locking, METH_VARARGS, msvcrt_locking__doc__}, + {"locking", (PyCFunction)msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, static PyObject * msvcrt_locking_impl(PyModuleDef *module, int fd, int mode, long nbytes); static PyObject * -msvcrt_locking(PyModuleDef *module, PyObject *args) +msvcrt_locking(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int mode; long nbytes; - if (!PyArg_ParseTuple(args, "iil:locking", + if (!PyArg_ParseStack(stack, nargs, "iil:locking", &fd, &mode, &nbytes)) goto exit; + if (!_PyArg_NoKeywords("locking()", kwargs)) + goto exit; return_value = msvcrt_locking_impl(module, fd, mode, nbytes); exit: @@ -71,22 +73,24 @@ PyDoc_STRVAR(msvcrt_setmode__doc__, "Return value is the previous mode."); #define MSVCRT_SETMODE_METHODDEF \ - {"setmode", (PyCFunction)msvcrt_setmode, METH_VARARGS, msvcrt_setmode__doc__}, + {"setmode", (PyCFunction)msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, static long msvcrt_setmode_impl(PyModuleDef *module, int fd, int flags); static PyObject * -msvcrt_setmode(PyModuleDef *module, PyObject *args) +msvcrt_setmode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int fd; int flags; long _return_value; - if (!PyArg_ParseTuple(args, "ii:setmode", + if (!PyArg_ParseStack(stack, nargs, "ii:setmode", &fd, &flags)) goto exit; + if (!_PyArg_NoKeywords("setmode()", kwargs)) + goto exit; _return_value = msvcrt_setmode_impl(module, fd, flags); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -107,23 +111,25 @@ PyDoc_STRVAR(msvcrt_open_osfhandle__doc_ "to os.fdopen() to create a file object."); #define MSVCRT_OPEN_OSFHANDLE_METHODDEF \ - {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_VARARGS, msvcrt_open_osfhandle__doc__}, + {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, static long msvcrt_open_osfhandle_impl(PyModuleDef *module, Py_intptr_t handle, int flags); static PyObject * -msvcrt_open_osfhandle(PyModuleDef *module, PyObject *args) +msvcrt_open_osfhandle(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_intptr_t handle; int flags; long _return_value; - if (!PyArg_ParseTuple(args, ""_Py_PARSE_INTPTR"i:open_osfhandle", + if (!PyArg_ParseStack(stack, nargs, ""_Py_PARSE_INTPTR"i:open_osfhandle", &handle, &flags)) goto exit; + if (!_PyArg_NoKeywords("open_osfhandle()", kwargs)) + goto exit; _return_value = msvcrt_open_osfhandle_impl(module, handle, flags); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -413,22 +419,24 @@ PyDoc_STRVAR(msvcrt_CrtSetReportFile__do "Only available on Debug builds."); #define MSVCRT_CRTSETREPORTFILE_METHODDEF \ - {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_VARARGS, msvcrt_CrtSetReportFile__doc__}, + {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, static long msvcrt_CrtSetReportFile_impl(PyModuleDef *module, int type, int file); static PyObject * -msvcrt_CrtSetReportFile(PyModuleDef *module, PyObject *args) +msvcrt_CrtSetReportFile(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int type; int file; long _return_value; - if (!PyArg_ParseTuple(args, "ii:CrtSetReportFile", + if (!PyArg_ParseStack(stack, nargs, "ii:CrtSetReportFile", &type, &file)) goto exit; + if (!_PyArg_NoKeywords("CrtSetReportFile()", kwargs)) + goto exit; _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -451,22 +459,24 @@ PyDoc_STRVAR(msvcrt_CrtSetReportMode__do "Only available on Debug builds."); #define MSVCRT_CRTSETREPORTMODE_METHODDEF \ - {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_VARARGS, msvcrt_CrtSetReportMode__doc__}, + {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, static long msvcrt_CrtSetReportMode_impl(PyModuleDef *module, int type, int mode); static PyObject * -msvcrt_CrtSetReportMode(PyModuleDef *module, PyObject *args) +msvcrt_CrtSetReportMode(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int type; int mode; long _return_value; - if (!PyArg_ParseTuple(args, "ii:CrtSetReportMode", + if (!PyArg_ParseStack(stack, nargs, "ii:CrtSetReportMode", &type, &mode)) goto exit; + if (!_PyArg_NoKeywords("CrtSetReportMode()", kwargs)) + goto exit; _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); if ((_return_value == -1) && PyErr_Occurred()) goto exit; @@ -551,4 +561,4 @@ exit: #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=16613d3119a1fd44 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=84f722d4c3a0ef0d input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb PC/clinic/winreg.c.h --- a/PC/clinic/winreg.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/PC/clinic/winreg.c.h Thu May 19 13:47:42 2016 +0200 @@ -77,14 +77,14 @@ PyDoc_STRVAR(winreg_HKEYType___exit____d "\n"); #define WINREG_HKEYTYPE___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)winreg_HKEYType___exit__, METH_VARARGS|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, + {"__exit__", (PyCFunction)winreg_HKEYType___exit__, METH_FASTCALL, winreg_HKEYType___exit____doc__}, static PyObject * winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, PyObject *exc_value, PyObject *traceback); static PyObject * -winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *args, PyObject *kwargs) +winreg_HKEYType___exit__(PyHKEYObject *self, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"exc_type", "exc_value", "traceback", NULL}; @@ -92,7 +92,7 @@ winreg_HKEYType___exit__(PyHKEYObject *s PyObject *exc_value; PyObject *traceback; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:__exit__", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "OOO:__exit__", _keywords, &exc_type, &exc_value, &traceback)) goto exit; return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback); @@ -132,23 +132,25 @@ PyDoc_STRVAR(winreg_ConnectRegistry__doc "If the function fails, an OSError exception is raised."); #define WINREG_CONNECTREGISTRY_METHODDEF \ - {"ConnectRegistry", (PyCFunction)winreg_ConnectRegistry, METH_VARARGS, winreg_ConnectRegistry__doc__}, + {"ConnectRegistry", (PyCFunction)winreg_ConnectRegistry, METH_FASTCALL, winreg_ConnectRegistry__doc__}, static HKEY winreg_ConnectRegistry_impl(PyModuleDef *module, Py_UNICODE *computer_name, HKEY key); static PyObject * -winreg_ConnectRegistry(PyModuleDef *module, PyObject *args) +winreg_ConnectRegistry(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_UNICODE *computer_name; HKEY key; HKEY _return_value; - if (!PyArg_ParseTuple(args, "ZO&:ConnectRegistry", + if (!PyArg_ParseStack(stack, nargs, "ZO&:ConnectRegistry", &computer_name, clinic_HKEY_converter, &key)) goto exit; + if (!_PyArg_NoKeywords("ConnectRegistry()", kwargs)) + goto exit; _return_value = winreg_ConnectRegistry_impl(module, computer_name, key); if (_return_value == NULL) goto exit; @@ -178,22 +180,24 @@ PyDoc_STRVAR(winreg_CreateKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEY_METHODDEF \ - {"CreateKey", (PyCFunction)winreg_CreateKey, METH_VARARGS, winreg_CreateKey__doc__}, + {"CreateKey", (PyCFunction)winreg_CreateKey, METH_FASTCALL, winreg_CreateKey__doc__}, static HKEY winreg_CreateKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key); static PyObject * -winreg_CreateKey(PyModuleDef *module, PyObject *args) +winreg_CreateKey(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *sub_key; HKEY _return_value; - if (!PyArg_ParseTuple(args, "O&Z:CreateKey", + if (!PyArg_ParseStack(stack, nargs, "O&Z:CreateKey", clinic_HKEY_converter, &key, &sub_key)) goto exit; + if (!_PyArg_NoKeywords("CreateKey()", kwargs)) + goto exit; _return_value = winreg_CreateKey_impl(module, key, sub_key); if (_return_value == NULL) goto exit; @@ -229,14 +233,14 @@ PyDoc_STRVAR(winreg_CreateKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEYEX_METHODDEF \ - {"CreateKeyEx", (PyCFunction)winreg_CreateKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, + {"CreateKeyEx", (PyCFunction)winreg_CreateKeyEx, METH_FASTCALL, winreg_CreateKeyEx__doc__}, static HKEY winreg_CreateKeyEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, int reserved, REGSAM access); static PyObject * -winreg_CreateKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) +winreg_CreateKeyEx(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; @@ -246,7 +250,7 @@ winreg_CreateKeyEx(PyModuleDef *module, REGSAM access = KEY_WRITE; HKEY _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:CreateKeyEx", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&Z|ii:CreateKeyEx", _keywords, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) goto exit; _return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access); @@ -277,21 +281,23 @@ PyDoc_STRVAR(winreg_DeleteKey__doc__, "is removed. If the function fails, an OSError exception is raised."); #define WINREG_DELETEKEY_METHODDEF \ - {"DeleteKey", (PyCFunction)winreg_DeleteKey, METH_VARARGS, winreg_DeleteKey__doc__}, + {"DeleteKey", (PyCFunction)winreg_DeleteKey, METH_FASTCALL, winreg_DeleteKey__doc__}, static PyObject * winreg_DeleteKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key); static PyObject * -winreg_DeleteKey(PyModuleDef *module, PyObject *args) +winreg_DeleteKey(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *sub_key; - if (!PyArg_ParseTuple(args, "O&u:DeleteKey", + if (!PyArg_ParseStack(stack, nargs, "O&u:DeleteKey", clinic_HKEY_converter, &key, &sub_key)) goto exit; + if (!_PyArg_NoKeywords("DeleteKey()", kwargs)) + goto exit; return_value = winreg_DeleteKey_impl(module, key, sub_key); exit: @@ -324,14 +330,14 @@ PyDoc_STRVAR(winreg_DeleteKeyEx__doc__, "On unsupported Windows versions, NotImplementedError is raised."); #define WINREG_DELETEKEYEX_METHODDEF \ - {"DeleteKeyEx", (PyCFunction)winreg_DeleteKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, + {"DeleteKeyEx", (PyCFunction)winreg_DeleteKeyEx, METH_FASTCALL, winreg_DeleteKeyEx__doc__}, static PyObject * winreg_DeleteKeyEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, REGSAM access, int reserved); static PyObject * -winreg_DeleteKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) +winreg_DeleteKeyEx(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"key", "sub_key", "access", "reserved", NULL}; @@ -340,7 +346,7 @@ winreg_DeleteKeyEx(PyModuleDef *module, REGSAM access = KEY_WOW64_64KEY; int reserved = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&u|ii:DeleteKeyEx", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&u|ii:DeleteKeyEx", _keywords, clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) goto exit; return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved); @@ -361,21 +367,23 @@ PyDoc_STRVAR(winreg_DeleteValue__doc__, " A string that identifies the value to remove."); #define WINREG_DELETEVALUE_METHODDEF \ - {"DeleteValue", (PyCFunction)winreg_DeleteValue, METH_VARARGS, winreg_DeleteValue__doc__}, + {"DeleteValue", (PyCFunction)winreg_DeleteValue, METH_FASTCALL, winreg_DeleteValue__doc__}, static PyObject * winreg_DeleteValue_impl(PyModuleDef *module, HKEY key, Py_UNICODE *value); static PyObject * -winreg_DeleteValue(PyModuleDef *module, PyObject *args) +winreg_DeleteValue(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *value; - if (!PyArg_ParseTuple(args, "O&Z:DeleteValue", + if (!PyArg_ParseStack(stack, nargs, "O&Z:DeleteValue", clinic_HKEY_converter, &key, &value)) goto exit; + if (!_PyArg_NoKeywords("DeleteValue()", kwargs)) + goto exit; return_value = winreg_DeleteValue_impl(module, key, value); exit: @@ -398,21 +406,23 @@ PyDoc_STRVAR(winreg_EnumKey__doc__, "raised, indicating no more values are available."); #define WINREG_ENUMKEY_METHODDEF \ - {"EnumKey", (PyCFunction)winreg_EnumKey, METH_VARARGS, winreg_EnumKey__doc__}, + {"EnumKey", (PyCFunction)winreg_EnumKey, METH_FASTCALL, winreg_EnumKey__doc__}, static PyObject * winreg_EnumKey_impl(PyModuleDef *module, HKEY key, int index); static PyObject * -winreg_EnumKey(PyModuleDef *module, PyObject *args) +winreg_EnumKey(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; int index; - if (!PyArg_ParseTuple(args, "O&i:EnumKey", + if (!PyArg_ParseStack(stack, nargs, "O&i:EnumKey", clinic_HKEY_converter, &key, &index)) goto exit; + if (!_PyArg_NoKeywords("EnumKey()", kwargs)) + goto exit; return_value = winreg_EnumKey_impl(module, key, index); exit: @@ -444,21 +454,23 @@ PyDoc_STRVAR(winreg_EnumValue__doc__, " An integer that identifies the type of the value data."); #define WINREG_ENUMVALUE_METHODDEF \ - {"EnumValue", (PyCFunction)winreg_EnumValue, METH_VARARGS, winreg_EnumValue__doc__}, + {"EnumValue", (PyCFunction)winreg_EnumValue, METH_FASTCALL, winreg_EnumValue__doc__}, static PyObject * winreg_EnumValue_impl(PyModuleDef *module, HKEY key, int index); static PyObject * -winreg_EnumValue(PyModuleDef *module, PyObject *args) +winreg_EnumValue(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; int index; - if (!PyArg_ParseTuple(args, "O&i:EnumValue", + if (!PyArg_ParseStack(stack, nargs, "O&i:EnumValue", clinic_HKEY_converter, &key, &index)) goto exit; + if (!_PyArg_NoKeywords("EnumValue()", kwargs)) + goto exit; return_value = winreg_EnumValue_impl(module, key, index); exit: @@ -559,23 +571,25 @@ PyDoc_STRVAR(winreg_LoadKey__doc__, "tree."); #define WINREG_LOADKEY_METHODDEF \ - {"LoadKey", (PyCFunction)winreg_LoadKey, METH_VARARGS, winreg_LoadKey__doc__}, + {"LoadKey", (PyCFunction)winreg_LoadKey, METH_FASTCALL, winreg_LoadKey__doc__}, static PyObject * winreg_LoadKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, Py_UNICODE *file_name); static PyObject * -winreg_LoadKey(PyModuleDef *module, PyObject *args) +winreg_LoadKey(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *sub_key; Py_UNICODE *file_name; - if (!PyArg_ParseTuple(args, "O&uu:LoadKey", + if (!PyArg_ParseStack(stack, nargs, "O&uu:LoadKey", clinic_HKEY_converter, &key, &sub_key, &file_name)) goto exit; + if (!_PyArg_NoKeywords("LoadKey()", kwargs)) + goto exit; return_value = winreg_LoadKey_impl(module, key, sub_key, file_name); exit: @@ -602,14 +616,14 @@ PyDoc_STRVAR(winreg_OpenKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEY_METHODDEF \ - {"OpenKey", (PyCFunction)winreg_OpenKey, METH_VARARGS|METH_KEYWORDS, winreg_OpenKey__doc__}, + {"OpenKey", (PyCFunction)winreg_OpenKey, METH_FASTCALL, winreg_OpenKey__doc__}, static HKEY winreg_OpenKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, int reserved, REGSAM access); static PyObject * -winreg_OpenKey(PyModuleDef *module, PyObject *args, PyObject *kwargs) +winreg_OpenKey(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; @@ -619,7 +633,7 @@ winreg_OpenKey(PyModuleDef *module, PyOb REGSAM access = KEY_READ; HKEY _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKey", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&Z|ii:OpenKey", _keywords, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) goto exit; _return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access); @@ -651,14 +665,14 @@ PyDoc_STRVAR(winreg_OpenKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEYEX_METHODDEF \ - {"OpenKeyEx", (PyCFunction)winreg_OpenKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, + {"OpenKeyEx", (PyCFunction)winreg_OpenKeyEx, METH_FASTCALL, winreg_OpenKeyEx__doc__}, static HKEY winreg_OpenKeyEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, int reserved, REGSAM access); static PyObject * -winreg_OpenKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) +winreg_OpenKeyEx(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; @@ -668,7 +682,7 @@ winreg_OpenKeyEx(PyModuleDef *module, Py REGSAM access = KEY_READ; HKEY _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKeyEx", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "O&Z|ii:OpenKeyEx", _keywords, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) goto exit; _return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access); @@ -736,21 +750,23 @@ PyDoc_STRVAR(winreg_QueryValue__doc__, "completeness."); #define WINREG_QUERYVALUE_METHODDEF \ - {"QueryValue", (PyCFunction)winreg_QueryValue, METH_VARARGS, winreg_QueryValue__doc__}, + {"QueryValue", (PyCFunction)winreg_QueryValue, METH_FASTCALL, winreg_QueryValue__doc__}, static PyObject * winreg_QueryValue_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key); static PyObject * -winreg_QueryValue(PyModuleDef *module, PyObject *args) +winreg_QueryValue(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *sub_key; - if (!PyArg_ParseTuple(args, "O&Z:QueryValue", + if (!PyArg_ParseStack(stack, nargs, "O&Z:QueryValue", clinic_HKEY_converter, &key, &sub_key)) goto exit; + if (!_PyArg_NoKeywords("QueryValue()", kwargs)) + goto exit; return_value = winreg_QueryValue_impl(module, key, sub_key); exit: @@ -774,21 +790,23 @@ PyDoc_STRVAR(winreg_QueryValueEx__doc__, "The return value is a tuple of the value and the type_id."); #define WINREG_QUERYVALUEEX_METHODDEF \ - {"QueryValueEx", (PyCFunction)winreg_QueryValueEx, METH_VARARGS, winreg_QueryValueEx__doc__}, + {"QueryValueEx", (PyCFunction)winreg_QueryValueEx, METH_FASTCALL, winreg_QueryValueEx__doc__}, static PyObject * winreg_QueryValueEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *name); static PyObject * -winreg_QueryValueEx(PyModuleDef *module, PyObject *args) +winreg_QueryValueEx(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *name; - if (!PyArg_ParseTuple(args, "O&Z:QueryValueEx", + if (!PyArg_ParseStack(stack, nargs, "O&Z:QueryValueEx", clinic_HKEY_converter, &key, &name)) goto exit; + if (!_PyArg_NoKeywords("QueryValueEx()", kwargs)) + goto exit; return_value = winreg_QueryValueEx_impl(module, key, name); exit: @@ -817,21 +835,23 @@ PyDoc_STRVAR(winreg_SaveKey__doc__, "to the API."); #define WINREG_SAVEKEY_METHODDEF \ - {"SaveKey", (PyCFunction)winreg_SaveKey, METH_VARARGS, winreg_SaveKey__doc__}, + {"SaveKey", (PyCFunction)winreg_SaveKey, METH_FASTCALL, winreg_SaveKey__doc__}, static PyObject * winreg_SaveKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *file_name); static PyObject * -winreg_SaveKey(PyModuleDef *module, PyObject *args) +winreg_SaveKey(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; Py_UNICODE *file_name; - if (!PyArg_ParseTuple(args, "O&u:SaveKey", + if (!PyArg_ParseStack(stack, nargs, "O&u:SaveKey", clinic_HKEY_converter, &key, &file_name)) goto exit; + if (!_PyArg_NoKeywords("SaveKey()", kwargs)) + goto exit; return_value = winreg_SaveKey_impl(module, key, file_name); exit: @@ -865,7 +885,7 @@ PyDoc_STRVAR(winreg_SetValue__doc__, "KEY_SET_VALUE access."); #define WINREG_SETVALUE_METHODDEF \ - {"SetValue", (PyCFunction)winreg_SetValue, METH_VARARGS, winreg_SetValue__doc__}, + {"SetValue", (PyCFunction)winreg_SetValue, METH_FASTCALL, winreg_SetValue__doc__}, static PyObject * winreg_SetValue_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, @@ -873,7 +893,7 @@ winreg_SetValue_impl(PyModuleDef *module Py_ssize_clean_t value_length); static PyObject * -winreg_SetValue(PyModuleDef *module, PyObject *args) +winreg_SetValue(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; @@ -882,9 +902,11 @@ winreg_SetValue(PyModuleDef *module, PyO Py_UNICODE *value; Py_ssize_clean_t value_length; - if (!PyArg_ParseTuple(args, "O&Zku#:SetValue", + if (!PyArg_ParseStack(stack, nargs, "O&Zku#:SetValue", clinic_HKEY_converter, &key, &sub_key, &type, &value, &value_length)) goto exit; + if (!_PyArg_NoKeywords("SetValue()", kwargs)) + goto exit; return_value = winreg_SetValue_impl(module, key, sub_key, type, value, value_length); exit: @@ -933,14 +955,14 @@ PyDoc_STRVAR(winreg_SetValueEx__doc__, "the configuration registry to help the registry perform efficiently."); #define WINREG_SETVALUEEX_METHODDEF \ - {"SetValueEx", (PyCFunction)winreg_SetValueEx, METH_VARARGS, winreg_SetValueEx__doc__}, + {"SetValueEx", (PyCFunction)winreg_SetValueEx, METH_FASTCALL, winreg_SetValueEx__doc__}, static PyObject * winreg_SetValueEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *value_name, PyObject *reserved, DWORD type, PyObject *value); static PyObject * -winreg_SetValueEx(PyModuleDef *module, PyObject *args) +winreg_SetValueEx(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; HKEY key; @@ -949,9 +971,11 @@ winreg_SetValueEx(PyModuleDef *module, P DWORD type; PyObject *value; - if (!PyArg_ParseTuple(args, "O&ZOkO:SetValueEx", + if (!PyArg_ParseStack(stack, nargs, "O&ZOkO:SetValueEx", clinic_HKEY_converter, &key, &value_name, &reserved, &type, &value)) goto exit; + if (!_PyArg_NoKeywords("SetValueEx()", kwargs)) + goto exit; return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value); exit: @@ -1056,4 +1080,4 @@ winreg_QueryReflectionKey(PyModuleDef *m exit: return return_value; } -/*[clinic end generated code: output=5e346dccc296f9f1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8c8d8b2073e09dcd input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb PC/clinic/winsound.c.h --- a/PC/clinic/winsound.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/PC/clinic/winsound.c.h Thu May 19 13:47:42 2016 +0200 @@ -14,21 +14,23 @@ PyDoc_STRVAR(winsound_PlaySound__doc__, " Flag values, ored together. See module documentation."); #define WINSOUND_PLAYSOUND_METHODDEF \ - {"PlaySound", (PyCFunction)winsound_PlaySound, METH_VARARGS, winsound_PlaySound__doc__}, + {"PlaySound", (PyCFunction)winsound_PlaySound, METH_FASTCALL, winsound_PlaySound__doc__}, static PyObject * winsound_PlaySound_impl(PyModuleDef *module, Py_UNICODE *sound, int flags); static PyObject * -winsound_PlaySound(PyModuleDef *module, PyObject *args) +winsound_PlaySound(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; Py_UNICODE *sound; int flags; - if (!PyArg_ParseTuple(args, "Zi:PlaySound", + if (!PyArg_ParseStack(stack, nargs, "Zi:PlaySound", &sound, &flags)) goto exit; + if (!_PyArg_NoKeywords("PlaySound()", kwargs)) + goto exit; return_value = winsound_PlaySound_impl(module, sound, flags); exit: @@ -48,21 +50,23 @@ PyDoc_STRVAR(winsound_Beep__doc__, " How long the sound should play, in milliseconds."); #define WINSOUND_BEEP_METHODDEF \ - {"Beep", (PyCFunction)winsound_Beep, METH_VARARGS, winsound_Beep__doc__}, + {"Beep", (PyCFunction)winsound_Beep, METH_FASTCALL, winsound_Beep__doc__}, static PyObject * winsound_Beep_impl(PyModuleDef *module, int frequency, int duration); static PyObject * -winsound_Beep(PyModuleDef *module, PyObject *args) +winsound_Beep(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int frequency; int duration; - if (!PyArg_ParseTuple(args, "ii:Beep", + if (!PyArg_ParseStack(stack, nargs, "ii:Beep", &frequency, &duration)) goto exit; + if (!_PyArg_NoKeywords("Beep()", kwargs)) + goto exit; return_value = winsound_Beep_impl(module, frequency, duration); exit: @@ -78,23 +82,25 @@ PyDoc_STRVAR(winsound_MessageBeep__doc__ "x defaults to MB_OK."); #define WINSOUND_MESSAGEBEEP_METHODDEF \ - {"MessageBeep", (PyCFunction)winsound_MessageBeep, METH_VARARGS, winsound_MessageBeep__doc__}, + {"MessageBeep", (PyCFunction)winsound_MessageBeep, METH_FASTCALL, winsound_MessageBeep__doc__}, static PyObject * winsound_MessageBeep_impl(PyModuleDef *module, int x); static PyObject * -winsound_MessageBeep(PyModuleDef *module, PyObject *args) +winsound_MessageBeep(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; int x = MB_OK; - if (!PyArg_ParseTuple(args, "|i:MessageBeep", + if (!PyArg_ParseStack(stack, nargs, "|i:MessageBeep", &x)) goto exit; + if (!_PyArg_NoKeywords("MessageBeep()", kwargs)) + goto exit; return_value = winsound_MessageBeep_impl(module, x); exit: return return_value; } -/*[clinic end generated code: output=c5b018ac9dc1f500 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=384ffc98033a37bd input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb PCbuild/pythoncore.vcxproj --- a/PCbuild/pythoncore.vcxproj Thu Apr 21 00:23:08 2016 -0700 +++ b/PCbuild/pythoncore.vcxproj Thu May 19 13:47:42 2016 +0200 @@ -144,6 +144,7 @@ + @@ -376,6 +377,7 @@ + @@ -416,4 +418,4 @@ - \ No newline at end of file + diff -r 496e094f4734 -r 34456cce64bb Parser/tokenizer.c --- a/Parser/tokenizer.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Parser/tokenizer.c Thu May 19 13:47:42 2016 +0200 @@ -440,7 +440,7 @@ fp_readl(char *s, int size, struct tok_s } else { - bufobj = PyObject_CallObject(tok->decoding_readline, NULL); + bufobj = PyObject_CallNoArg(tok->decoding_readline); if (bufobj == NULL) goto error; } @@ -528,10 +528,11 @@ fp_setreadl(struct tok_state *tok, const readline = _PyObject_GetAttrId(stream, &PyId_readline); Py_XSETREF(tok->decoding_readline, readline); if (pos > 0) { - if (PyObject_CallObject(readline, NULL) == NULL) { + if (PyObject_CallNoArg(readline) == NULL) { readline = NULL; goto cleanup; } + /* FIXME: refleak if readline() succeed? */ } cleanup: @@ -648,7 +649,7 @@ decoding_feof(struct tok_state *tok) } else { PyObject* buf = tok->decoding_buffer; if (buf == NULL) { - buf = PyObject_CallObject(tok->decoding_readline, NULL); + buf = PyObject_CallNoArg(tok->decoding_readline); if (buf == NULL) { error_ret(tok); return 1; diff -r 496e094f4734 -r 34456cce64bb Python/ast.c --- a/Python/ast.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/ast.c Thu May 19 13:47:42 2016 +0200 @@ -577,7 +577,6 @@ struct compiling { PyArena *c_arena; /* Arena for allocating memory. */ PyObject *c_filename; /* filename */ PyObject *c_normalize; /* Normalization function from unicodedata. */ - PyObject *c_normalize_args; /* Normalization argument tuple. */ }; static asdl_seq *seq_for_testlist(struct compiling *, const node *); @@ -612,19 +611,16 @@ init_normalization(struct compiling *c) Py_DECREF(m); if (!c->c_normalize) return 0; - c->c_normalize_args = Py_BuildValue("(sN)", "NFKC", Py_None); - if (!c->c_normalize_args) { - Py_CLEAR(c->c_normalize); - return 0; - } - PyTuple_SET_ITEM(c->c_normalize_args, 1, NULL); return 1; } static identifier new_identifier(const char *n, struct compiling *c) { - PyObject *id = PyUnicode_DecodeUTF8(n, strlen(n), NULL); + PyObject *id; + _Py_IDENTIFIER(NFKC); + + id = PyUnicode_DecodeUTF8(n, strlen(n), NULL); if (!id) return NULL; /* PyUnicode_DecodeUTF8 should always return a ready string. */ @@ -632,13 +628,23 @@ new_identifier(const char *n, struct com /* Check whether there are non-ASCII characters in the identifier; if so, normalize to NFKC. */ if (!PyUnicode_IS_ASCII(id)) { - PyObject *id2; + PyObject *id2, *nfkc; + PyObject *stack[2]; + if (!c->c_normalize && !init_normalization(c)) { Py_DECREF(id); return NULL; } - PyTuple_SET_ITEM(c->c_normalize_args, 1, id); - id2 = PyObject_Call(c->c_normalize, c->c_normalize_args, NULL); + + nfkc = _PyUnicode_FromId(&PyId_NFKC); + if (nfkc == NULL) { + Py_DECREF(id); + return NULL; + } + + stack[0] = nfkc; + stack[1] = id; + id2 = _PyObject_FastCall(c->c_normalize, stack, 2, NULL); Py_DECREF(id); if (!id2) return NULL; @@ -761,7 +767,6 @@ PyAST_FromNodeObject(const node *n, PyCo /* borrowed reference */ c.c_filename = filename; c.c_normalize = NULL; - c.c_normalize_args = NULL; if (TYPE(n) == encoding_decl) n = CHILD(n, 0); @@ -854,8 +859,6 @@ PyAST_FromNodeObject(const node *n, PyCo out: if (c.c_normalize) { Py_DECREF(c.c_normalize); - PyTuple_SET_ITEM(c.c_normalize_args, 1, NULL); - Py_DECREF(c.c_normalize_args); } return res; } diff -r 496e094f4734 -r 34456cce64bb Python/bltinmodule.c --- a/Python/bltinmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/bltinmodule.c Thu May 19 13:47:42 2016 +0200 @@ -50,38 +50,30 @@ int Py_HasFileSystemDefaultEncoding = 0; /* AC: cannot convert yet, waiting for *args support */ static PyObject * -builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) +builtin___build_class__(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { PyObject *func, *name, *bases, *mkw, *meta, *winner, *prep, *ns, *cell; PyObject *cls = NULL; - Py_ssize_t nargs; int isclass = 0; /* initialize to prevent gcc warning */ - assert(args != NULL); - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_TypeError, - "__build_class__: args is not a tuple"); - return NULL; - } - nargs = PyTuple_GET_SIZE(args); if (nargs < 2) { PyErr_SetString(PyExc_TypeError, "__build_class__: not enough arguments"); return NULL; } - func = PyTuple_GET_ITEM(args, 0); /* Better be callable */ + func = stack[0]; /* Better be callable */ if (!PyFunction_Check(func)) { PyErr_SetString(PyExc_TypeError, "__build_class__: func must be a function"); return NULL; } - name = PyTuple_GET_ITEM(args, 1); + name = stack[1]; if (!PyUnicode_Check(name)) { PyErr_SetString(PyExc_TypeError, "__build_class__: name is not a string"); return NULL; } - bases = PyTuple_GetSlice(args, 2, nargs); + bases = _PyStack_AsTupleSlice(stack, nargs, 2, nargs); if (bases == NULL) return NULL; @@ -155,16 +147,11 @@ builtin___build_class__(PyObject *self, } } else { - PyObject *pargs = PyTuple_Pack(2, name, bases); - if (pargs == NULL) { - Py_DECREF(prep); - Py_DECREF(meta); - Py_XDECREF(mkw); - Py_DECREF(bases); - return NULL; - } - ns = PyEval_CallObjectWithKeywords(prep, pargs, mkw); - Py_DECREF(pargs); + PyObject *stack[2]; + + stack[0] = name; + stack[1] = bases; + ns = _PyObject_FastCall(prep, stack, 2, mkw); Py_DECREF(prep); } if (ns == NULL) { @@ -177,12 +164,13 @@ builtin___build_class__(PyObject *self, NULL, 0, NULL, 0, NULL, 0, NULL, PyFunction_GET_CLOSURE(func)); if (cell != NULL) { - PyObject *margs; - margs = PyTuple_Pack(3, name, bases, ns); - if (margs != NULL) { - cls = PyEval_CallObjectWithKeywords(meta, margs, mkw); - Py_DECREF(margs); - } + PyObject* stack[3]; + + stack[0] = name; + stack[1] = bases; + stack[2] = ns; + cls = _PyObject_FastCall(meta, stack, 3, mkw); + if (cls != NULL && PyCell_Check(cell)) PyCell_Set(cell, cls); Py_DECREF(cell); @@ -200,14 +188,14 @@ PyDoc_STRVAR(build_class_doc, Internal helper function used by the class statement."); static PyObject * -builtin___import__(PyObject *self, PyObject *args, PyObject *kwds) +builtin___import__(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; PyObject *name, *globals = NULL, *locals = NULL, *fromlist = NULL; int level = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "U|OOOi:__import__", + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwds, "U|OOOi:__import__", kwlist, &name, &globals, &locals, &fromlist, &level)) return NULL; return PyImport_ImportModuleLevelObject(name, globals, locals, @@ -481,7 +469,7 @@ filter_next(filterobject *lz) ok = PyObject_IsTrue(item); } else { PyObject *good; - good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); + good = PyObject_CallArg1(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -982,13 +970,22 @@ builtin_exec_impl(PyModuleDef *module, P /* AC: cannot convert yet, as needs PEP 457 group support in inspect */ static PyObject * -builtin_getattr(PyObject *self, PyObject *args) +builtin_getattr(PyObject *self, PyObject **stack, int na, PyObject *kwargs) { - PyObject *v, *result, *dflt = NULL; + PyObject *v, *result, *dflt; PyObject *name; - if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt)) + if (_PyStack_CheckArgs(stack, na, kwargs, "getattr", 2, 3) < 0) { return NULL; + } + v = stack[0]; + name = stack[1]; + if (na >= 3) { + dflt = stack[2]; + } + else { + dflt = NULL; + } if (!PyUnicode_Check(name)) { PyErr_SetString(PyExc_TypeError, @@ -1105,16 +1102,15 @@ typedef struct { } mapobject; static PyObject * -map_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +map_new(PyTypeObject *type, PyObject **stack, int numargs, PyObject *kwds) { PyObject *it, *iters, *func; mapobject *lz; - Py_ssize_t numargs, i; - - if (type == &PyMap_Type && !_PyArg_NoKeywords("map()", kwds)) + Py_ssize_t i; + + if (type == &PyMap_Type && kwds != NULL && !_PyArg_NoKeywords("map()", kwds)) return NULL; - numargs = PyTuple_Size(args); if (numargs < 2) { PyErr_SetString(PyExc_TypeError, "map() must have at least two arguments."); @@ -1127,7 +1123,7 @@ map_new(PyTypeObject *type, PyObject *ar for (i=1 ; iiters = iters; - func = PyTuple_GET_ITEM(args, 0); + func = stack[0]; Py_INCREF(func); lz->func = func; @@ -1170,26 +1166,31 @@ static PyObject * map_next(mapobject *lz) { PyObject *val; - PyObject *argtuple; PyObject *result; Py_ssize_t numargs, i; + PyObject* small_stack[_PyStack_SIZE]; + PyObject **stack; numargs = PyTuple_GET_SIZE(lz->iters); - argtuple = PyTuple_New(numargs); - if (argtuple == NULL) + + stack = _PyStack_ALLOC(small_stack, numargs); + if (stack == NULL) { return NULL; + } for (i=0 ; iiters, i); val = Py_TYPE(it)->tp_iternext(it); if (val == NULL) { - Py_DECREF(argtuple); + _PyStack_Free(stack, small_stack, i); return NULL; } - PyTuple_SET_ITEM(argtuple, i, val); + stack[i] = val; } - result = PyObject_Call(lz->func, argtuple, NULL); - Py_DECREF(argtuple); + + result = _PyObject_FastCall(lz->func, stack, numargs, NULL); + _PyStack_Free(stack, small_stack, numargs); + return result; } @@ -1246,7 +1247,7 @@ PyTypeObject PyMap_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_FASTNEW, /* tp_flags */ map_doc, /* tp_doc */ (traverseproc)map_traverse, /* tp_traverse */ 0, /* tp_clear */ @@ -1264,20 +1265,24 @@ PyTypeObject PyMap_Type = { 0, /* tp_dictoffset */ 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - map_new, /* tp_new */ + (newfunc)map_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; /* AC: cannot convert yet, as needs PEP 457 group support in inspect */ static PyObject * -builtin_next(PyObject *self, PyObject *args) +builtin_next(PyObject *self, PyObject **stack, int na, PyObject *kwargs) { PyObject *it, *res; PyObject *def = NULL; - if (!PyArg_UnpackTuple(args, "next", 1, 2, &it, &def)) + if (_PyStack_CheckArgs(stack, na, kwargs, "next", 1, 2) < 0) { return NULL; + } + it = stack[0]; + def = (na >= 2) ? stack[1] : NULL; + if (!PyIter_Check(it)) { PyErr_Format(PyExc_TypeError, "'%.200s' object is not an iterator", @@ -1406,14 +1411,19 @@ builtin_hex(PyModuleDef *module, PyObjec /* AC: cannot convert yet, as needs PEP 457 group support in inspect */ static PyObject * -builtin_iter(PyObject *self, PyObject *args) +builtin_iter(PyObject *self, PyObject **stack, int na, PyObject *kwargs) { - PyObject *v, *w = NULL; - - if (!PyArg_UnpackTuple(args, "iter", 1, 2, &v, &w)) + PyObject *v, *w; + + if (_PyStack_CheckArgsKeywords(stack, na, kwargs, "iter", 1, 2) < 0) { return NULL; - if (w == NULL) + } + v = stack[0]; + if (na == 1) { return PyObject_GetIter(v); + } + + w = stack[1]; if (!PyCallable_Check(v)) { PyErr_SetString(PyExc_TypeError, "iter(v, w): v must be callable"); @@ -1516,7 +1526,7 @@ min_max(PyObject *args, PyObject *kwds, while (( item = PyIter_Next(it) )) { /* get the value from the key function */ if (keyfunc != NULL) { - val = PyObject_CallFunctionObjArgs(keyfunc, item, NULL); + val = PyObject_CallArg1(keyfunc, item); if (val == NULL) goto Fail_it_item; } @@ -1709,7 +1719,7 @@ builtin_pow_impl(PyModuleDef *module, Py /* AC: cannot convert yet, waiting for *args support */ static PyObject * -builtin_print(PyObject *self, PyObject *args, PyObject *kwds) +builtin_print(PyObject *self, PyObject **stack, int nargs, PyObject *kwds) { static char *kwlist[] = {"sep", "end", "file", "flush", 0}; static PyObject *dummy_args; @@ -1752,7 +1762,7 @@ builtin_print(PyObject *self, PyObject * return NULL; } - for (i = 0; i < PyTuple_Size(args); i++) { + for (i = 0; i < nargs; i++) { if (i > 0) { if (sep == NULL) err = PyFile_WriteString(" ", file); @@ -1762,8 +1772,7 @@ builtin_print(PyObject *self, PyObject * if (err) return NULL; } - err = PyFile_WriteObject(PyTuple_GetItem(args, i), file, - Py_PRINT_RAW); + err = PyFile_WriteObject(stack[i], file, Py_PRINT_RAW); if (err) return NULL; } @@ -2041,9 +2050,9 @@ builtin_round(PyObject *self, PyObject * } if (ndigits == NULL) - result = PyObject_CallFunctionObjArgs(round, NULL); + result = PyObject_CallNoArg(round); else - result = PyObject_CallFunctionObjArgs(round, ndigits, NULL); + result = PyObject_CallArg1(round, ndigits); Py_DECREF(round); return result; } @@ -2083,20 +2092,20 @@ PyDoc_STRVAR(builtin_sorted__doc__, "reverse flag can be set to request the result in descending order."); #define BUILTIN_SORTED_METHODDEF \ - {"sorted", (PyCFunction)builtin_sorted, METH_VARARGS|METH_KEYWORDS, builtin_sorted__doc__}, + {"sorted", (PyCFunction)builtin_sorted, METH_FASTCALL, builtin_sorted__doc__}, static PyObject * -builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds) +builtin_sorted(PyObject *self, PyObject **stack, int na, PyObject *kwargs) { - PyObject *newlist, *v, *seq, *keyfunc=NULL, *newargs; + PyObject *newlist, *v, *seq; PyObject *callable; - static char *kwlist[] = {"iterable", "key", "reverse", 0}; - int reverse; /* args 1-3 should match listsort in Objects/listobject.c */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted", - kwlist, &seq, &keyfunc, &reverse)) + if (_PyStack_CheckArgsKeywords(stack, na, kwargs, "sorted", 1, 3) < 0) { return NULL; + } + /* FIXME: validate also types: "O|Oi:sorted" and keywords? */ + seq = stack[0]; newlist = PySequence_List(seq); if (newlist == NULL) @@ -2108,15 +2117,7 @@ builtin_sorted(PyObject *self, PyObject return NULL; } - newargs = PyTuple_GetSlice(args, 1, 4); - if (newargs == NULL) { - Py_DECREF(newlist); - Py_DECREF(callable); - return NULL; - } - - v = PyObject_Call(callable, newargs, kwds); - Py_DECREF(newargs); + v = _PyObject_FastCall(callable, stack + 1, na - 1, kwargs); Py_DECREF(callable); if (v == NULL) { Py_DECREF(newlist); @@ -2584,8 +2585,8 @@ PyTypeObject PyZip_Type = { static PyMethodDef builtin_methods[] = { {"__build_class__", (PyCFunction)builtin___build_class__, - METH_VARARGS | METH_KEYWORDS, build_class_doc}, - {"__import__", (PyCFunction)builtin___import__, METH_VARARGS | METH_KEYWORDS, import_doc}, + METH_FASTCALL, build_class_doc}, + {"__import__", (PyCFunction)builtin___import__, METH_FASTCALL, import_doc}, BUILTIN_ABS_METHODDEF BUILTIN_ALL_METHODDEF BUILTIN_ANY_METHODDEF @@ -2600,7 +2601,7 @@ static PyMethodDef builtin_methods[] = { BUILTIN_EVAL_METHODDEF BUILTIN_EXEC_METHODDEF BUILTIN_FORMAT_METHODDEF - {"getattr", builtin_getattr, METH_VARARGS, getattr_doc}, + {"getattr", (PyCFunction)builtin_getattr, METH_FASTCALL, getattr_doc}, BUILTIN_GLOBALS_METHODDEF BUILTIN_HASATTR_METHODDEF BUILTIN_HASH_METHODDEF @@ -2609,16 +2610,16 @@ static PyMethodDef builtin_methods[] = { BUILTIN_INPUT_METHODDEF BUILTIN_ISINSTANCE_METHODDEF BUILTIN_ISSUBCLASS_METHODDEF - {"iter", builtin_iter, METH_VARARGS, iter_doc}, + {"iter", (PyCFunction)builtin_iter, METH_FASTCALL, iter_doc}, BUILTIN_LEN_METHODDEF BUILTIN_LOCALS_METHODDEF {"max", (PyCFunction)builtin_max, METH_VARARGS | METH_KEYWORDS, max_doc}, {"min", (PyCFunction)builtin_min, METH_VARARGS | METH_KEYWORDS, min_doc}, - {"next", (PyCFunction)builtin_next, METH_VARARGS, next_doc}, + {"next", (PyCFunction)builtin_next, METH_FASTCALL, next_doc}, BUILTIN_OCT_METHODDEF BUILTIN_ORD_METHODDEF BUILTIN_POW_METHODDEF - {"print", (PyCFunction)builtin_print, METH_VARARGS | METH_KEYWORDS, print_doc}, + {"print", (PyCFunction)builtin_print, METH_FASTCALL, print_doc}, BUILTIN_REPR_METHODDEF {"round", (PyCFunction)builtin_round, METH_VARARGS | METH_KEYWORDS, round_doc}, BUILTIN_SETATTR_METHODDEF diff -r 496e094f4734 -r 34456cce64bb Python/ceval.c --- a/Python/ceval.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/ceval.c Thu May 19 13:47:42 2016 +0200 @@ -20,6 +20,9 @@ #include +/* Forward */ +static PyObject* load_args(PyObject ***pp_stack, int na); + #ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -113,13 +116,12 @@ static PyObject * call_function(PyObject #else static PyObject * call_function(PyObject ***, int); #endif -static PyObject * fast_function(PyObject *, PyObject ***, int, int, int); +static PyObject * fast_function(PyObject *, PyObject ***, int, int); static PyObject * do_call(PyObject *, PyObject ***, int, int); static PyObject * ext_do_call(PyObject *, PyObject ***, int, int, int); static PyObject * update_keyword_args(PyObject *, int, PyObject ***, PyObject *); static PyObject * update_star_args(int, int, PyObject *, PyObject ***); -static PyObject * load_args(PyObject ***, int); #define CALL_FLAG_VAR 1 #define CALL_FLAG_KW 2 @@ -2746,6 +2748,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int Py_INCREF(func); from = POP(); level = TOP(); + /* FIXME: fastcall */ if (PyLong_AsLong(level) != -1 || PyErr_Occurred()) args = PyTuple_Pack(5, name, @@ -2769,7 +2772,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int goto error; } READ_TIMESTAMP(intr0); - res = PyEval_CallObject(func, args); + res = PyObject_Call(func, args, NULL); READ_TIMESTAMP(intr1); Py_DECREF(args); Py_DECREF(func); @@ -3044,7 +3047,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int Py_DECREF(mgr); if (enter == NULL) goto error; - res = PyObject_CallFunctionObjArgs(enter, NULL); + res = PyObject_CallNoArg(enter); Py_DECREF(enter); if (res == NULL) goto error; @@ -3075,7 +3078,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int Py_DECREF(mgr); if (enter == NULL) goto error; - res = PyObject_CallFunctionObjArgs(enter, NULL); + res = PyObject_CallNoArg(enter); Py_DECREF(enter); if (res == NULL) goto error; @@ -3114,6 +3117,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int gotos should still be resumed.) */ + PyObject *arg_stack[3]; PyObject *exit_func; PyObject *exc = TOP(), *val = Py_None, *tb = Py_None, *res; if (exc == Py_None) { @@ -3159,8 +3163,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int assert(block->b_type == EXCEPT_HANDLER); block->b_level--; } - /* XXX Not the fastest way to call it... */ - res = PyObject_CallFunctionObjArgs(exit_func, exc, val, tb, NULL); + arg_stack[0] = exc; + arg_stack[1] = val; + arg_stack[2] = tb; + res = _PyObject_FastCall(exit_func, arg_stack, 3, 0); Py_DECREF(exit_func); if (res == NULL) goto error; @@ -4034,7 +4040,8 @@ static PyObject * if (is_coro && coro_wrapper != NULL) { PyObject *wrapped; tstate->in_coroutine_wrapper = 1; - wrapped = PyObject_CallFunction(coro_wrapper, "N", gen); + wrapped = PyObject_CallArg1(coro_wrapper, gen); + Py_DECREF(gen); tstate->in_coroutine_wrapper = 0; return wrapped; } @@ -4058,10 +4065,317 @@ fail: /* Jump here from prelude on failu return retval; } +static int +fastlocals_dict(PyObject **fastlocals, PyCodeObject *co, int total_args, PyObject *kwdict, PyObject *kwargs) +{ + _Py_IDENTIFIER(items); + PyObject *items, *iter; + PyObject *item = NULL; + + assert(PyDict_Check(kwargs)); + + items = _PyObject_CallMethodId((PyObject *)kwargs, &PyId_items, NULL); + if (items == NULL) { + return -1; + } + + iter = PyObject_GetIter(items); + Py_DECREF(items); + if (iter == NULL) { + goto fail; + } + + do { + PyObject **co_varnames; + PyObject *keyword, *value; + int j; + + /* Get first item */ + item = PyIter_Next(iter); + if (item == NULL) { + if (PyErr_Occurred()) { + goto fail; + } + + /* nothing more to add */ + break; + } + assert(PyTuple_CheckExact(item) && PyTuple_GET_SIZE(item) == 2); + + keyword = PyTuple_GET_ITEM(item, 0); + value = PyTuple_GET_ITEM(item, 1); + + + if (keyword == NULL || !PyUnicode_Check(keyword)) { + PyErr_Format(PyExc_TypeError, + "%U() keywords must be strings", + co->co_name); + goto fail; + } + /* Speed hack: do raw pointer compares. As names are + normally interned this should almost always hit. */ + co_varnames = ((PyTupleObject *)(co->co_varnames))->ob_item; + for (j = 0; j < total_args; j++) { + PyObject *nm = co_varnames[j]; + if (nm == keyword) + goto kw_found; + } + /* Slow fallback, just in case */ + for (j = 0; j < total_args; j++) { + PyObject *nm = co_varnames[j]; + int cmp = PyObject_RichCompareBool( + keyword, nm, Py_EQ); + if (cmp > 0) + goto kw_found; + else if (cmp < 0) + goto fail; + } + if (j >= total_args && kwdict == NULL) { + PyErr_Format(PyExc_TypeError, + "%U() got an unexpected " + "keyword argument '%S'", + co->co_name, + keyword); + goto fail; + } + if (PyDict_SetItem(kwdict, keyword, value) == -1) { + goto fail; + } + Py_DECREF(item); + continue; + + kw_found: + if (GETLOCAL(j) != NULL) { + PyErr_Format(PyExc_TypeError, + "%U() got multiple " + "values for argument '%S'", + co->co_name, + keyword); + goto fail; + } + Py_INCREF(value); + SETLOCAL(j, value); + + Py_DECREF(item); + /* FIXME: it "item = NULL" needed? */ + item = NULL; + } while (1); + + Py_DECREF(iter); + return 0; + +fail: + Py_DECREF(iter); + Py_XDECREF(item); + return -1; +} + +static PyObject * +_PyEval_EvalCodeWithDict(PyObject *_co, PyObject *globals, PyObject *locals, + PyObject **args, int argcount, PyObject *kwargs, + PyObject **defs, int defcount, PyObject *kwdefs, + PyObject *closure, + PyObject *name, PyObject *qualname) +{ + /* FIXME: Factorize code with _PyEval_EvalCodeWithName */ + PyCodeObject* co = (PyCodeObject*)_co; + PyFrameObject *f; + PyObject *retval = NULL; + PyObject **fastlocals, **freevars; + PyThreadState *tstate = PyThreadState_GET(); + PyObject *x, *u; + int total_args = co->co_argcount + co->co_kwonlyargcount; + int i; + int n = argcount; + PyObject *kwdict = NULL; + + if (globals == NULL) { + PyErr_SetString(PyExc_SystemError, + "PyEval_EvalCodeEx: NULL globals"); + return NULL; + } + + assert(tstate != NULL); + assert(globals != NULL); + f = PyFrame_New(tstate, co, globals, locals); + if (f == NULL) + return NULL; + + fastlocals = f->f_localsplus; + freevars = f->f_localsplus + co->co_nlocals; + + /* Parse arguments. */ + if (co->co_flags & CO_VARKEYWORDS) { + kwdict = PyDict_New(); + if (kwdict == NULL) + goto fail; + i = total_args; + if (co->co_flags & CO_VARARGS) + i++; + SETLOCAL(i, kwdict); + } + if (argcount > co->co_argcount) + n = co->co_argcount; + for (i = 0; i < n; i++) { + x = args[i]; + Py_INCREF(x); + SETLOCAL(i, x); + } + if (co->co_flags & CO_VARARGS) { + u = PyTuple_New(argcount - n); + if (u == NULL) + goto fail; + SETLOCAL(total_args, u); + for (i = n; i < argcount; i++) { + x = args[i]; + Py_INCREF(x); + PyTuple_SET_ITEM(u, i-n, x); + } + } + if (kwargs != NULL) { + if (fastlocals_dict(fastlocals, co, total_args, kwdict, kwargs) < 0) { + goto fail; + } + } + if (argcount > co->co_argcount && !(co->co_flags & CO_VARARGS)) { + too_many_positional(co, argcount, defcount, fastlocals); + goto fail; + } + if (argcount < co->co_argcount) { + int m = co->co_argcount - defcount; + int missing = 0; + for (i = argcount; i < m; i++) + if (GETLOCAL(i) == NULL) + missing++; + if (missing) { + missing_arguments(co, missing, defcount, fastlocals); + goto fail; + } + if (n > m) + i = n - m; + else + i = 0; + for (; i < defcount; i++) { + if (GETLOCAL(m+i) == NULL) { + PyObject *def = defs[i]; + Py_INCREF(def); + SETLOCAL(m+i, def); + } + } + } + if (co->co_kwonlyargcount > 0) { + int missing = 0; + for (i = co->co_argcount; i < total_args; i++) { + PyObject *name; + if (GETLOCAL(i) != NULL) + continue; + name = PyTuple_GET_ITEM(co->co_varnames, i); + if (kwdefs != NULL) { + PyObject *def = PyDict_GetItem(kwdefs, name); + if (def) { + Py_INCREF(def); + SETLOCAL(i, def); + continue; + } + } + missing++; + } + if (missing) { + missing_arguments(co, missing, -1, fastlocals); + goto fail; + } + } + + /* Allocate and initialize storage for cell vars, and copy free + vars into frame. */ + for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) { + PyObject *c; + int arg; + /* Possibly account for the cell variable being an argument. */ + if (co->co_cell2arg != NULL && + (arg = co->co_cell2arg[i]) != CO_CELL_NOT_AN_ARG) { + c = PyCell_New(GETLOCAL(arg)); + /* Clear the local copy. */ + SETLOCAL(arg, NULL); + } + else { + c = PyCell_New(NULL); + } + if (c == NULL) + goto fail; + SETLOCAL(co->co_nlocals + i, c); + } + for (i = 0; i < PyTuple_GET_SIZE(co->co_freevars); ++i) { + PyObject *o = PyTuple_GET_ITEM(closure, i); + Py_INCREF(o); + freevars[PyTuple_GET_SIZE(co->co_cellvars) + i] = o; + } + + if (co->co_flags & (CO_GENERATOR | CO_COROUTINE)) { + PyObject *gen; + PyObject *coro_wrapper = tstate->coroutine_wrapper; + int is_coro = co->co_flags & CO_COROUTINE; + + if (is_coro && tstate->in_coroutine_wrapper) { + assert(coro_wrapper != NULL); + PyErr_Format(PyExc_RuntimeError, + "coroutine wrapper %.200R attempted " + "to recursively wrap %.200R", + coro_wrapper, + co); + goto fail; + } + + /* Don't need to keep the reference to f_back, it will be set + * when the generator is resumed. */ + Py_CLEAR(f->f_back); + + PCALL(PCALL_GENERATOR); + + /* Create a new generator that owns the ready to run frame + * and return that as the value. */ + if (is_coro) { + gen = PyCoro_New(f, name, qualname); + } else { + gen = PyGen_NewWithQualName(f, name, qualname); + } + if (gen == NULL) + return NULL; + + if (is_coro && coro_wrapper != NULL) { + PyObject *wrapped; + tstate->in_coroutine_wrapper = 1; + wrapped = PyObject_CallArg1(coro_wrapper, gen); + Py_DECREF(gen); + tstate->in_coroutine_wrapper = 0; + return wrapped; + } + + return gen; + } + + retval = PyEval_EvalFrameEx(f,0); + +fail: /* Jump here from prelude on failure */ + + /* decref'ing the frame can cause __del__ methods to get invoked, + which can call back into Python. While we're done with the + current Python frame (f), the associated C stack is still in use, + so recursion_depth must be boosted for the duration. + */ + assert(tstate != NULL); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return retval; +} + PyObject * PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, - PyObject **args, int argcount, PyObject **kws, int kwcount, - PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure) + PyObject **args, int argcount, + PyObject **kws, int kwcount, + PyObject **defs, int defcount, PyObject *kwdefs, + PyObject *closure) { return _PyEval_EvalCodeWithName(_co, globals, locals, args, argcount, kws, kwcount, @@ -4169,7 +4483,7 @@ do_raise(PyObject *exc, PyObject *cause) if (PyExceptionClass_Check(exc)) { type = exc; - value = PyObject_CallObject(exc, NULL); + value = PyObject_CallNoArg(exc); if (value == NULL) goto raise_error; if (!PyExceptionInstance_Check(value)) { @@ -4197,7 +4511,7 @@ do_raise(PyObject *exc, PyObject *cause) if (cause) { PyObject *fixed_cause; if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); + fixed_cause = PyObject_CallNoArg(cause); if (fixed_cause == NULL) goto raise_error; Py_DECREF(cause); @@ -4575,8 +4889,6 @@ PyEval_MergeCompilerFlags(PyCompilerFlag PyObject * PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - #ifdef Py_DEBUG /* PyEval_CallObjectWithKeywords() must not be called with an exception set. It raises a new exception if parameters are invalid or if @@ -4585,29 +4897,22 @@ PyEval_CallObjectWithKeywords(PyObject * #endif if (arg == NULL) { - arg = PyTuple_New(0); - if (arg == NULL) - return NULL; + return _PyObject_FastCall(func, NULL, 0, kw); } - else if (!PyTuple_Check(arg)) { + + if (!PyTuple_Check(arg)) { PyErr_SetString(PyExc_TypeError, "argument list must be a tuple"); return NULL; } - else - Py_INCREF(arg); if (kw != NULL && !PyDict_Check(kw)) { PyErr_SetString(PyExc_TypeError, "keyword list must be a dictionary"); - Py_DECREF(arg); return NULL; } - result = PyObject_Call(func, arg, kw); - Py_DECREF(arg); - - return result; + return PyObject_Call(func, arg, kw); } const char * @@ -4691,31 +4996,35 @@ call_function(PyObject ***pp_stack, int { int na = oparg & 0xff; int nk = (oparg>>8) & 0xff; - int n = na + 2 * nk; - PyObject **pfunc = (*pp_stack) - n - 1; + PyObject **pfunc = (*pp_stack) - (na + 2 * nk) - 1; PyObject *func = *pfunc; PyObject *x, *w; - /* Always dispatch PyCFunction first, because these are - presumed to be the most frequent callable object. - */ + /* FIXME: FASTCALL with nk != 0 */ if (PyCFunction_Check(func) && nk == 0) { - int flags = PyCFunction_GET_FLAGS(func); + int flags = PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); PyThreadState *tstate = PyThreadState_GET(); PCALL(PCALL_CFUNCTION); - if (flags & (METH_NOARGS | METH_O)) { - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - if (flags & METH_NOARGS && na == 0) { - C_TRACE(x, (*meth)(self,NULL)); + + switch (flags) + { + case METH_FASTCALL: + { + PyObject *self = PyCFunction_GET_SELF(func); + fastternaryfunc meth = (fastternaryfunc)PyCFunction_GET_FUNCTION(func); + /* take the fast-path with keywords? */ + C_TRACE(x, (*meth)(self, (*pp_stack) - (na + 2 * nk), na, NULL)); x = _Py_CheckFunctionResult(func, x, NULL); } - else if (flags & METH_O && na == 1) { - PyObject *arg = EXT_POP(*pp_stack); - C_TRACE(x, (*meth)(self,arg)); - Py_DECREF(arg); + break; + + case METH_NOARGS: + if (na == 0) { + PyObject *self = PyCFunction_GET_SELF(func); + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + C_TRACE(x, (*meth)(self, NULL)); x = _Py_CheckFunctionResult(func, x, NULL); } @@ -4723,19 +5032,38 @@ call_function(PyObject ***pp_stack, int err_args(func, flags, na); x = NULL; } - } - else { - PyObject *callargs; - callargs = load_args(pp_stack, na); - if (callargs != NULL) { - READ_TIMESTAMP(*pintr0); - C_TRACE(x, PyCFunction_Call(func,callargs,NULL)); - READ_TIMESTAMP(*pintr1); - Py_XDECREF(callargs); + break; + + case METH_O: + if (na == 1) { + PyObject *arg = EXT_POP(*pp_stack); + PyObject *self = PyCFunction_GET_SELF(func); + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + C_TRACE(x, (*meth)(self, arg)); + Py_DECREF(arg); + + x = _Py_CheckFunctionResult(func, x, NULL); } else { + err_args(func, flags, na); x = NULL; } + break; + + default: + { + PyObject *callargs; + callargs = load_args(pp_stack, na); + if (callargs != NULL) { + READ_TIMESTAMP(*pintr0); + C_TRACE(x, PyCFunction_Call(func, callargs, NULL)); + READ_TIMESTAMP(*pintr1); + Py_XDECREF(callargs); + } + else { + x = NULL; + } + } } } else { @@ -4749,24 +5077,25 @@ call_function(PyObject ***pp_stack, int Py_INCREF(func); Py_SETREF(*pfunc, self); na++; - n++; - } else + } + else { Py_INCREF(func); + } + READ_TIMESTAMP(*pintr0); - if (PyFunction_Check(func)) - x = fast_function(func, pp_stack, n, na, nk); - else + if (PyFunction_Check(func)) { + x = fast_function(func, pp_stack, na, nk); + } + else { x = do_call(func, pp_stack, na, nk); + } READ_TIMESTAMP(*pintr1); Py_DECREF(func); assert((x != NULL) ^ (PyErr_Occurred() != NULL)); } - /* Clear the stack of the function object. Also removes - the arguments in case they weren't consumed already - (fast_function() and err_args() leave them on the stack). - */ + /* Clear the stack of the function object. */ while ((*pp_stack) > pfunc) { w = EXT_POP(*pp_stack); Py_DECREF(w); @@ -4777,7 +5106,7 @@ call_function(PyObject ***pp_stack, int return x; } -/* The fast_function() function optimize calls for which no argument +/* The _PyFunction_FastCall() function optimize calls for which no argument tuple is necessary; the objects are passed directly from the stack. For the simplest case -- a function that takes only positional arguments and is called with only positional arguments -- it @@ -4787,8 +5116,9 @@ call_function(PyObject ***pp_stack, int */ static PyObject * -fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) +fast_function(PyObject *func, PyObject ***pp_stack, int na, int nk) { + const int n = na + 2 * nk; PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); @@ -4798,6 +5128,10 @@ fast_function(PyObject *func, PyObject * PyObject **d = NULL; int nd = 0; + assert(PyFunction_Check(func)); + assert(na >= 0); + assert(nk >= 0); + PCALL(PCALL_FUNCTION); PCALL(PCALL_FAST_FUNCTION); if (argdefs == NULL && co->co_argcount == n && @@ -4844,6 +5178,73 @@ fast_function(PyObject *func, PyObject * name, qualname); } + +/* Note: fast_function() must be a local function (declared with static) for + best performances of the CALL_FUNCTION opcode. */ +PyObject * +_PyFunction_FastCall(PyObject *func, PyObject **stack, int na, PyObject *kwargs) +{ + /* FIXME: try to factorize _PyFunction_FastCall() and fast_function() + without killing performances? */ + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *kwdefs = PyFunction_GET_KW_DEFAULTS(func); + PyObject *name = ((PyFunctionObject *)func) -> func_name; + PyObject *qualname = ((PyFunctionObject *)func) -> func_qualname; + PyObject **d = NULL; + int nd = 0; + + assert(PyFunction_Check(func)); + assert(na >= 0); + + PCALL(PCALL_FUNCTION); + PCALL(PCALL_FAST_FUNCTION); + if (argdefs == NULL && co->co_argcount == na && + /* FIXME: fast path for empty dict */ + co->co_kwonlyargcount == 0 && kwargs == NULL && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + PyFrameObject *f; + PyObject *retval = NULL; + PyThreadState *tstate = PyThreadState_GET(); + PyObject **fastlocals; + int i; + + PCALL(PCALL_FASTER_FUNCTION); + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) + return NULL; + + fastlocals = f->f_localsplus; + + for (i = 0; i < na; i++) { + Py_INCREF(*stack); + fastlocals[i] = *stack++; + } + retval = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return retval; + } + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + + return _PyEval_EvalCodeWithDict((PyObject*)co, globals, + (PyObject *)NULL, stack, na, + kwargs, d, nd, kwdefs, + PyFunction_GET_CLOSURE(func), + name, qualname); +} + static PyObject * update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack, PyObject *func) @@ -4940,20 +5341,19 @@ load_args(PyObject ***pp_stack, int na) } static PyObject * -do_call(PyObject *func, PyObject ***pp_stack, int na, int nk) +do_call(PyObject *func, PyObject ***pp_stack, int nargs, int nk) { - PyObject *callargs = NULL; + PyObject *result; PyObject *kwdict = NULL; - PyObject *result = NULL; + PyObject **stack = *pp_stack - nargs - nk * 2; if (nk > 0) { kwdict = update_keyword_args(NULL, nk, pp_stack, func); - if (kwdict == NULL) - goto call_fail; + if (kwdict == NULL) { + return NULL; + } } - callargs = load_args(pp_stack, na); - if (callargs == NULL) - goto call_fail; + #ifdef CALL_PROFILE /* At this point, we have to look at the type of func to update the call stats properly. Do it here so as to avoid @@ -4970,15 +5370,17 @@ do_call(PyObject *func, PyObject ***pp_s else PCALL(PCALL_OTHER); #endif + if (PyCFunction_Check(func)) { PyThreadState *tstate = PyThreadState_GET(); - C_TRACE(result, PyCFunction_Call(func, callargs, kwdict)); + C_TRACE(result, _PyCFunction_FastCall(func, stack, nargs, kwdict)); } - else - result = PyObject_Call(func, callargs, kwdict); -call_fail: - Py_XDECREF(callargs); + else { + result = _PyObject_FastCall(func, stack, nargs, kwdict); + } Py_XDECREF(kwdict); + + result = _Py_CheckFunctionResult(func, result, NULL); return result; } @@ -5049,9 +5451,6 @@ ext_do_call(PyObject *func, PyObject *** } nstar = PyTuple_GET_SIZE(stararg); } - callargs = update_star_args(na, nstar, stararg, pp_stack); - if (callargs == NULL) - goto ext_call_fail; #ifdef CALL_PROFILE /* At this point, we have to look at the type of func to update the call stats properly. Do it here so as to avoid @@ -5068,12 +5467,42 @@ ext_do_call(PyObject *func, PyObject *** else PCALL(PCALL_OTHER); #endif - if (PyCFunction_Check(func)) { - PyThreadState *tstate = PyThreadState_GET(); - C_TRACE(result, PyCFunction_Call(func, callargs, kwdict)); + if (nstar == 0) { + if (PyCFunction_Check(func)) { + PyThreadState *tstate = PyThreadState_GET(); + C_TRACE(result, _PyCFunction_FastCall(func, *pp_stack - na, na, kwdict)); + } + else { + result = _PyObject_FastCall(func, *pp_stack - na, na, kwdict); + } } - else - result = PyObject_Call(func, callargs, kwdict); + else if (na == 0) { + PyObject **stack; + + assert(PyTuple_Check(stararg)); + stack = ((PyTupleObject *)stararg)->ob_item; + if (PyCFunction_Check(func)) { + PyThreadState *tstate = PyThreadState_GET(); + C_TRACE(result, _PyCFunction_FastCall(func, stack, nstar, kwdict)); + } + else { + result = _PyObject_FastCall(func, stack, nstar, kwdict); + } + } + else { + callargs = update_star_args(na, nstar, stararg, pp_stack); + if (callargs == NULL) + goto ext_call_fail; + + if (PyCFunction_Check(func)) { + PyThreadState *tstate = PyThreadState_GET(); + C_TRACE(result, PyCFunction_Call(func, callargs, kwdict)); + } + else { + result = PyObject_Call(func, callargs, kwdict); + } + } + ext_call_fail: Py_XDECREF(callargs); Py_XDECREF(kwdict); diff -r 496e094f4734 -r 34456cce64bb Python/clinic/bltinmodule.c.h --- a/Python/clinic/bltinmodule.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/clinic/bltinmodule.c.h Thu May 19 13:47:42 2016 +0200 @@ -80,22 +80,24 @@ PyDoc_STRVAR(builtin_format__doc__, "format_spec defaults to the empty string"); #define BUILTIN_FORMAT_METHODDEF \ - {"format", (PyCFunction)builtin_format, METH_VARARGS, builtin_format__doc__}, + {"format", (PyCFunction)builtin_format, METH_FASTCALL, builtin_format__doc__}, static PyObject * builtin_format_impl(PyModuleDef *module, PyObject *value, PyObject *format_spec); static PyObject * -builtin_format(PyModuleDef *module, PyObject *args) +builtin_format(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *value; PyObject *format_spec = NULL; - if (!PyArg_ParseTuple(args, "O|U:format", + if (!PyArg_ParseStack(stack, nargs, "O|U:format", &value, &format_spec)) goto exit; + if (!_PyArg_NoKeywords("format()", kwargs)) + goto exit; return_value = builtin_format_impl(module, value, format_spec); exit: @@ -147,7 +149,7 @@ PyDoc_STRVAR(builtin_compile__doc__, "in addition to any features explicitly specified."); #define BUILTIN_COMPILE_METHODDEF \ - {"compile", (PyCFunction)builtin_compile, METH_VARARGS|METH_KEYWORDS, builtin_compile__doc__}, + {"compile", (PyCFunction)builtin_compile, METH_FASTCALL, builtin_compile__doc__}, static PyObject * builtin_compile_impl(PyModuleDef *module, PyObject *source, @@ -155,7 +157,7 @@ builtin_compile_impl(PyModuleDef *module int dont_inherit, int optimize); static PyObject * -builtin_compile(PyModuleDef *module, PyObject *args, PyObject *kwargs) +builtin_compile(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", NULL}; @@ -166,7 +168,7 @@ builtin_compile(PyModuleDef *module, PyO int dont_inherit = 0; int optimize = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO&s|iii:compile", _keywords, + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "OO&s|iii:compile", _keywords, &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) goto exit; return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize); @@ -182,22 +184,24 @@ PyDoc_STRVAR(builtin_divmod__doc__, "Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x."); #define BUILTIN_DIVMOD_METHODDEF \ - {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__}, + {"divmod", (PyCFunction)builtin_divmod, METH_FASTCALL, builtin_divmod__doc__}, static PyObject * builtin_divmod_impl(PyModuleDef *module, PyObject *x, PyObject *y); static PyObject * -builtin_divmod(PyModuleDef *module, PyObject *args) +builtin_divmod(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *x; PyObject *y; - if (!PyArg_UnpackTuple(args, "divmod", + if (!PyArg_UnpackStack(stack, nargs, "divmod", 2, 2, &x, &y)) goto exit; + if (!_PyArg_NoKeywords("divmod", kwargs)) + goto exit; return_value = builtin_divmod_impl(module, x, y); exit: @@ -217,24 +221,26 @@ PyDoc_STRVAR(builtin_eval__doc__, "If only globals is given, locals defaults to it."); #define BUILTIN_EVAL_METHODDEF \ - {"eval", (PyCFunction)builtin_eval, METH_VARARGS, builtin_eval__doc__}, + {"eval", (PyCFunction)builtin_eval, METH_FASTCALL, builtin_eval__doc__}, static PyObject * builtin_eval_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals); static PyObject * -builtin_eval(PyModuleDef *module, PyObject *args) +builtin_eval(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *source; PyObject *globals = Py_None; PyObject *locals = Py_None; - if (!PyArg_UnpackTuple(args, "eval", + if (!PyArg_UnpackStack(stack, nargs, "eval", 1, 3, &source, &globals, &locals)) goto exit; + if (!_PyArg_NoKeywords("eval", kwargs)) + goto exit; return_value = builtin_eval_impl(module, source, globals, locals); exit: @@ -254,24 +260,26 @@ PyDoc_STRVAR(builtin_exec__doc__, "If only globals is given, locals defaults to it."); #define BUILTIN_EXEC_METHODDEF \ - {"exec", (PyCFunction)builtin_exec, METH_VARARGS, builtin_exec__doc__}, + {"exec", (PyCFunction)builtin_exec, METH_FASTCALL, builtin_exec__doc__}, static PyObject * builtin_exec_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals); static PyObject * -builtin_exec(PyModuleDef *module, PyObject *args) +builtin_exec(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *source; PyObject *globals = Py_None; PyObject *locals = Py_None; - if (!PyArg_UnpackTuple(args, "exec", + if (!PyArg_UnpackStack(stack, nargs, "exec", 1, 3, &source, &globals, &locals)) goto exit; + if (!_PyArg_NoKeywords("exec", kwargs)) + goto exit; return_value = builtin_exec_impl(module, source, globals, locals); exit: @@ -308,22 +316,24 @@ PyDoc_STRVAR(builtin_hasattr__doc__, "This is done by calling getattr(obj, name) and catching AttributeError."); #define BUILTIN_HASATTR_METHODDEF \ - {"hasattr", (PyCFunction)builtin_hasattr, METH_VARARGS, builtin_hasattr__doc__}, + {"hasattr", (PyCFunction)builtin_hasattr, METH_FASTCALL, builtin_hasattr__doc__}, static PyObject * builtin_hasattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name); static PyObject * -builtin_hasattr(PyModuleDef *module, PyObject *args) +builtin_hasattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *obj; PyObject *name; - if (!PyArg_UnpackTuple(args, "hasattr", + if (!PyArg_UnpackStack(stack, nargs, "hasattr", 2, 2, &obj, &name)) goto exit; + if (!_PyArg_NoKeywords("hasattr", kwargs)) + goto exit; return_value = builtin_hasattr_impl(module, obj, name); exit: @@ -351,24 +361,26 @@ PyDoc_STRVAR(builtin_setattr__doc__, "setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'"); #define BUILTIN_SETATTR_METHODDEF \ - {"setattr", (PyCFunction)builtin_setattr, METH_VARARGS, builtin_setattr__doc__}, + {"setattr", (PyCFunction)builtin_setattr, METH_FASTCALL, builtin_setattr__doc__}, static PyObject * builtin_setattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name, PyObject *value); static PyObject * -builtin_setattr(PyModuleDef *module, PyObject *args) +builtin_setattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *obj; PyObject *name; PyObject *value; - if (!PyArg_UnpackTuple(args, "setattr", + if (!PyArg_UnpackStack(stack, nargs, "setattr", 3, 3, &obj, &name, &value)) goto exit; + if (!_PyArg_NoKeywords("setattr", kwargs)) + goto exit; return_value = builtin_setattr_impl(module, obj, name, value); exit: @@ -384,22 +396,24 @@ PyDoc_STRVAR(builtin_delattr__doc__, "delattr(x, \'y\') is equivalent to ``del x.y\'\'"); #define BUILTIN_DELATTR_METHODDEF \ - {"delattr", (PyCFunction)builtin_delattr, METH_VARARGS, builtin_delattr__doc__}, + {"delattr", (PyCFunction)builtin_delattr, METH_FASTCALL, builtin_delattr__doc__}, static PyObject * builtin_delattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name); static PyObject * -builtin_delattr(PyModuleDef *module, PyObject *args) +builtin_delattr(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *obj; PyObject *name; - if (!PyArg_UnpackTuple(args, "delattr", + if (!PyArg_UnpackStack(stack, nargs, "delattr", 2, 2, &obj, &name)) goto exit; + if (!_PyArg_NoKeywords("delattr", kwargs)) + goto exit; return_value = builtin_delattr_impl(module, obj, name); exit: @@ -492,23 +506,25 @@ PyDoc_STRVAR(builtin_pow__doc__, "invoked using the three argument form."); #define BUILTIN_POW_METHODDEF \ - {"pow", (PyCFunction)builtin_pow, METH_VARARGS, builtin_pow__doc__}, + {"pow", (PyCFunction)builtin_pow, METH_FASTCALL, builtin_pow__doc__}, static PyObject * builtin_pow_impl(PyModuleDef *module, PyObject *x, PyObject *y, PyObject *z); static PyObject * -builtin_pow(PyModuleDef *module, PyObject *args) +builtin_pow(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *x; PyObject *y; PyObject *z = Py_None; - if (!PyArg_UnpackTuple(args, "pow", + if (!PyArg_UnpackStack(stack, nargs, "pow", 2, 3, &x, &y, &z)) goto exit; + if (!_PyArg_NoKeywords("pow", kwargs)) + goto exit; return_value = builtin_pow_impl(module, x, y, z); exit: @@ -528,21 +544,23 @@ PyDoc_STRVAR(builtin_input__doc__, "On *nix systems, readline is used if available."); #define BUILTIN_INPUT_METHODDEF \ - {"input", (PyCFunction)builtin_input, METH_VARARGS, builtin_input__doc__}, + {"input", (PyCFunction)builtin_input, METH_FASTCALL, builtin_input__doc__}, static PyObject * builtin_input_impl(PyModuleDef *module, PyObject *prompt); static PyObject * -builtin_input(PyModuleDef *module, PyObject *args) +builtin_input(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *prompt = NULL; - if (!PyArg_UnpackTuple(args, "input", + if (!PyArg_UnpackStack(stack, nargs, "input", 0, 1, &prompt)) goto exit; + if (!_PyArg_NoKeywords("input", kwargs)) + goto exit; return_value = builtin_input_impl(module, prompt); exit: @@ -571,22 +589,24 @@ PyDoc_STRVAR(builtin_sum__doc__, "reject non-numeric types."); #define BUILTIN_SUM_METHODDEF \ - {"sum", (PyCFunction)builtin_sum, METH_VARARGS, builtin_sum__doc__}, + {"sum", (PyCFunction)builtin_sum, METH_FASTCALL, builtin_sum__doc__}, static PyObject * builtin_sum_impl(PyModuleDef *module, PyObject *iterable, PyObject *start); static PyObject * -builtin_sum(PyModuleDef *module, PyObject *args) +builtin_sum(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *iterable; PyObject *start = NULL; - if (!PyArg_UnpackTuple(args, "sum", + if (!PyArg_UnpackStack(stack, nargs, "sum", 1, 2, &iterable, &start)) goto exit; + if (!_PyArg_NoKeywords("sum", kwargs)) + goto exit; return_value = builtin_sum_impl(module, iterable, start); exit: @@ -604,23 +624,25 @@ PyDoc_STRVAR(builtin_isinstance__doc__, "or ...`` etc."); #define BUILTIN_ISINSTANCE_METHODDEF \ - {"isinstance", (PyCFunction)builtin_isinstance, METH_VARARGS, builtin_isinstance__doc__}, + {"isinstance", (PyCFunction)builtin_isinstance, METH_FASTCALL, builtin_isinstance__doc__}, static PyObject * builtin_isinstance_impl(PyModuleDef *module, PyObject *obj, PyObject *class_or_tuple); static PyObject * -builtin_isinstance(PyModuleDef *module, PyObject *args) +builtin_isinstance(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *obj; PyObject *class_or_tuple; - if (!PyArg_UnpackTuple(args, "isinstance", + if (!PyArg_UnpackStack(stack, nargs, "isinstance", 2, 2, &obj, &class_or_tuple)) goto exit; + if (!_PyArg_NoKeywords("isinstance", kwargs)) + goto exit; return_value = builtin_isinstance_impl(module, obj, class_or_tuple); exit: @@ -638,26 +660,28 @@ PyDoc_STRVAR(builtin_issubclass__doc__, "or ...`` etc."); #define BUILTIN_ISSUBCLASS_METHODDEF \ - {"issubclass", (PyCFunction)builtin_issubclass, METH_VARARGS, builtin_issubclass__doc__}, + {"issubclass", (PyCFunction)builtin_issubclass, METH_FASTCALL, builtin_issubclass__doc__}, static PyObject * builtin_issubclass_impl(PyModuleDef *module, PyObject *cls, PyObject *class_or_tuple); static PyObject * -builtin_issubclass(PyModuleDef *module, PyObject *args) +builtin_issubclass(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *cls; PyObject *class_or_tuple; - if (!PyArg_UnpackTuple(args, "issubclass", + if (!PyArg_UnpackStack(stack, nargs, "issubclass", 2, 2, &cls, &class_or_tuple)) goto exit; + if (!_PyArg_NoKeywords("issubclass", kwargs)) + goto exit; return_value = builtin_issubclass_impl(module, cls, class_or_tuple); exit: return return_value; } -/*[clinic end generated code: output=bec3399c0aee98d7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0cc099bb3c0cf54f input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Python/clinic/import.c.h --- a/Python/clinic/import.c.h Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/clinic/import.c.h Thu May 19 13:47:42 2016 +0200 @@ -75,22 +75,24 @@ PyDoc_STRVAR(_imp__fix_co_filename__doc_ " File path to use."); #define _IMP__FIX_CO_FILENAME_METHODDEF \ - {"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_VARARGS, _imp__fix_co_filename__doc__}, + {"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_FASTCALL, _imp__fix_co_filename__doc__}, static PyObject * _imp__fix_co_filename_impl(PyModuleDef *module, PyCodeObject *code, PyObject *path); static PyObject * -_imp__fix_co_filename(PyModuleDef *module, PyObject *args) +_imp__fix_co_filename(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyCodeObject *code; PyObject *path; - if (!PyArg_ParseTuple(args, "O!U:_fix_co_filename", + if (!PyArg_ParseStack(stack, nargs, "O!U:_fix_co_filename", &PyCode_Type, &code, &path)) goto exit; + if (!_PyArg_NoKeywords("_fix_co_filename()", kwargs)) + goto exit; return_value = _imp__fix_co_filename_impl(module, code, path); exit: @@ -263,22 +265,24 @@ PyDoc_STRVAR(_imp_create_dynamic__doc__, "Create an extension module."); #define _IMP_CREATE_DYNAMIC_METHODDEF \ - {"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_VARARGS, _imp_create_dynamic__doc__}, + {"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_FASTCALL, _imp_create_dynamic__doc__}, static PyObject * _imp_create_dynamic_impl(PyModuleDef *module, PyObject *spec, PyObject *file); static PyObject * -_imp_create_dynamic(PyModuleDef *module, PyObject *args) +_imp_create_dynamic(PyModuleDef *module, PyObject **stack, int nargs, PyObject *kwargs) { PyObject *return_value = NULL; PyObject *spec; PyObject *file = NULL; - if (!PyArg_UnpackTuple(args, "create_dynamic", + if (!PyArg_UnpackStack(stack, nargs, "create_dynamic", 1, 2, &spec, &file)) goto exit; + if (!_PyArg_NoKeywords("create_dynamic", kwargs)) + goto exit; return_value = _imp_create_dynamic_impl(module, spec, file); exit: @@ -352,4 +356,4 @@ exit: #ifndef _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */ -/*[clinic end generated code: output=32324a5e46cdfc4b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=68eab9e351ade711 input=a9049054013a1b77]*/ diff -r 496e094f4734 -r 34456cce64bb Python/codecs.c --- a/Python/codecs.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/codecs.c Thu May 19 13:47:42 2016 +0200 @@ -101,7 +101,7 @@ PyObject *normalizestring(const char *st PyObject *_PyCodec_Lookup(const char *encoding) { PyInterpreterState *interp; - PyObject *result, *args = NULL, *v; + PyObject *result, *v; Py_ssize_t i, len; if (encoding == NULL) { @@ -130,11 +130,6 @@ PyObject *_PyCodec_Lookup(const char *en } /* Next, scan the search functions in order of registration */ - args = PyTuple_New(1); - if (args == NULL) - goto onError; - PyTuple_SET_ITEM(args,0,v); - len = PyList_Size(interp->codec_search_path); if (len < 0) goto onError; @@ -151,7 +146,7 @@ PyObject *_PyCodec_Lookup(const char *en func = PyList_GetItem(interp->codec_search_path, i); if (func == NULL) goto onError; - result = PyEval_CallObject(func, args); + result = PyObject_CallArg1(func, v); if (result == NULL) goto onError; if (result == Py_None) { @@ -178,11 +173,9 @@ PyObject *_PyCodec_Lookup(const char *en Py_DECREF(result); goto onError; } - Py_DECREF(args); return result; onError: - Py_XDECREF(args); return NULL; } @@ -417,11 +410,12 @@ static PyObject * PyObject *args = NULL, *result = NULL; PyObject *v = NULL; + /* FIXME: fastcall */ args = args_tuple(object, errors); if (args == NULL) goto onError; - result = PyEval_CallObject(encoder, args); + result = PyObject_Call(encoder, args, NULL); if (result == NULL) { wrap_codec_error("encoding", encoding); goto onError; @@ -467,7 +461,8 @@ static PyObject * if (args == NULL) goto onError; - result = PyEval_CallObject(decoder,args); + /* FIXME: fastcall */ + result = PyObject_Call(decoder, args, NULL); if (result == NULL) { wrap_codec_error("decoding", encoding); goto onError; diff -r 496e094f4734 -r 34456cce64bb Python/errors.c --- a/Python/errors.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/errors.c Thu May 19 13:47:42 2016 +0200 @@ -52,6 +52,20 @@ PyErr_Restore(PyObject *type, PyObject * Py_XDECREF(oldtraceback); } +static PyObject* +_PyErr_CreateException(PyObject *type, PyObject *value) +{ + if (value == NULL) { + return PyObject_CallNoArg(type); + } + else if (PyTuple_Check(value)) { + return PyObject_Call(type, value, NULL); + } + else { + return PyObject_CallArg1(type, value); + } +} + void PyErr_SetObject(PyObject *exception, PyObject *value) { @@ -73,23 +87,14 @@ PyErr_SetObject(PyObject *exception, PyO Py_INCREF(exc_value); if (value == NULL || !PyExceptionInstance_Check(value)) { /* We must normalize the value right now */ - PyObject *args, *fixed_value; + PyObject *fixed_value; - /* Issue #23571: PyEval_CallObject() must not be called with an + /* Issue #23571: PyObject_Call() must not be called with an exception set */ PyErr_Clear(); - if (value == NULL || value == Py_None) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } - else - args = PyTuple_Pack(1, value); - fixed_value = args ? - PyEval_CallObject(exception, args) : NULL; - Py_XDECREF(args); + /* FIXME: fast-path */ + fixed_value = _PyErr_CreateException(exception, value); Py_XDECREF(value); if (fixed_value == NULL) return; @@ -258,21 +263,10 @@ PyErr_NormalizeException(PyObject **exc, class. */ if (!inclass || !is_subclass) { - PyObject *args, *res; + PyObject *res; - if (value == Py_None) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } - else - args = PyTuple_Pack(1, value); + res = _PyErr_CreateException(type, value != Py_None ? value : NULL); - if (args == NULL) - goto finally; - res = PyEval_CallObject(type, args); - Py_DECREF(args); if (res == NULL) goto finally; Py_DECREF(value); @@ -432,11 +426,14 @@ PyObject * PyErr_SetFromErrnoWithFilenameObjects(PyObject *exc, PyObject *filenameObject, PyObject *filenameObject2) { PyObject *message; - PyObject *v, *args; + PyObject *v; int i = errno; #ifdef MS_WINDOWS WCHAR *s_buf = NULL; #endif /* Unix/Windows */ + PyObject* small_stack[5]; + PyObject **stack; + int na; #ifdef EINTR if (i == EINTR && PyErr_CheckSignals()) @@ -501,20 +498,27 @@ PyErr_SetFromErrnoWithFilenameObjects(Py return NULL; } + /* FIXME: use PyObject_CallFunction to simplify the code? */ if (filenameObject != NULL) { - if (filenameObject2 != NULL) - args = Py_BuildValue("(iOOiO)", i, message, filenameObject, 0, filenameObject2); - else - args = Py_BuildValue("(iOO)", i, message, filenameObject); - } else { + if (filenameObject2 != NULL) { + stack = Py_BuildStack(small_stack, Py_ARRAY_LENGTH(small_stack), &na, + "(iOOiO)", i, message, filenameObject, 0, filenameObject2); + } + else { + stack = Py_BuildStack(small_stack, Py_ARRAY_LENGTH(small_stack), &na, + "(iOO)", i, message, filenameObject); + } + } + else { assert(filenameObject2 == NULL); - args = Py_BuildValue("(iO)", i, message); + stack = Py_BuildStack(small_stack, Py_ARRAY_LENGTH(small_stack), &na, + "(iO)", i, message); } Py_DECREF(message); - if (args != NULL) { - v = PyObject_Call(exc, args, NULL); - Py_DECREF(args); + if (stack != NULL) { + v = _PyObject_FastCall(exc, stack, na, NULL); + _PyStack_Free(stack, small_stack, na); if (v != NULL) { PyErr_SetObject((PyObject *) Py_TYPE(v), v); Py_DECREF(v); @@ -574,7 +578,7 @@ PyObject *PyErr_SetExcFromWindowsErrWith int len; WCHAR *s_buf = NULL; /* Free via LocalFree */ PyObject *message; - PyObject *args, *v; + PyObject *v; DWORD err = (DWORD)ierr; if (err==0) err = GetLastError(); len = FormatMessageW( @@ -612,19 +616,17 @@ PyObject *PyErr_SetExcFromWindowsErrWith } else if (filenameObject2 == NULL) filenameObject2 = Py_None; + /* This is the constructor signature for OSError. The POSIX translation will be figured out by the constructor. */ - args = Py_BuildValue("(iOOiO)", 0, message, filenameObject, err, filenameObject2); + v = PyObject_CallFunction(exc, "iOOiO", 0, message, filenameObject, err, filenameObject2); Py_DECREF(message); - if (args != NULL) { - v = PyObject_Call(exc, args, NULL); - Py_DECREF(args); - if (v != NULL) { - PyErr_SetObject((PyObject *) Py_TYPE(v), v); - Py_DECREF(v); - } + if (v != NULL) { + PyErr_SetObject((PyObject *) Py_TYPE(v), v); + Py_DECREF(v); } + LocalFree(s_buf); return NULL; } @@ -700,18 +702,13 @@ PyObject *PyErr_SetFromWindowsErrWithUni PyObject * PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) { - PyObject *args, *kwargs, *error; + PyObject *kwargs, *error; if (msg == NULL) return NULL; - args = PyTuple_New(1); - if (args == NULL) - return NULL; - kwargs = PyDict_New(); if (kwargs == NULL) { - Py_DECREF(args); return NULL; } @@ -723,21 +720,17 @@ PyErr_SetImportError(PyObject *msg, PyOb path = Py_None; } - Py_INCREF(msg); - PyTuple_SET_ITEM(args, 0, msg); - if (PyDict_SetItemString(kwargs, "name", name) < 0) return NULL; if (PyDict_SetItemString(kwargs, "path", path) < 0) return NULL; - error = PyObject_Call(PyExc_ImportError, args, kwargs); + error = _PyObject_FastCall(PyExc_ImportError, &msg, 1, kwargs); if (error != NULL) { PyErr_SetObject((PyObject *)Py_TYPE(error), error); Py_DECREF(error); } - Py_DECREF(args); Py_DECREF(kwargs); return NULL; diff -r 496e094f4734 -r 34456cce64bb Python/getargs.c --- a/Python/getargs.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/getargs.c Thu May 19 13:47:42 2016 +0200 @@ -55,6 +55,7 @@ typedef struct { /* Forward */ static int vgetargs1(PyObject *, const char *, va_list *, int); +static int vgetstack1(PyObject **stack, Py_ssize_t len, const char *format, va_list *p_va, int flags); static void seterror(Py_ssize_t, const char *, int *, const char *, const char *); static const char *convertitem(PyObject *, const char **, va_list *, int, int *, char *, size_t, freelist_t *); @@ -65,6 +66,9 @@ static const char *convertsimple(PyObjec static Py_ssize_t convertbuffer(PyObject *, void **p, const char **); static int getbuffer(PyObject *, Py_buffer *, const char**); +static int vgetstackkeywords(PyObject **stack, Py_ssize_t nargs, + PyObject *keywords, const char *format, + char **kwlist, va_list *p_va, int flags); static int vgetargskeywords(PyObject *, PyObject *, const char *, char **, va_list *, int); static const char *skipitem(const char **, va_list *, int); @@ -118,6 +122,29 @@ int return retval; } +int +PyArg_ParseStack(PyObject **stack, int nargs, const char *format, ...) +{ + int retval; + va_list va; + + va_start(va, format); + retval = vgetstack1(stack, nargs, format, &va, 0); + va_end(va); + return retval; +} + +int +_PyArg_ParseStack_SizeT(PyObject **stack, int nargs, const char *format, ...) +{ + int retval; + va_list va; + + va_start(va, format); + retval = vgetstack1(stack, nargs, format, &va, FLAG_SIZE_T); + va_end(va); + return retval; +} int PyArg_VaParse(PyObject *args, const char *format, va_list va) @@ -195,6 +222,132 @@ cleanreturn(int retval, freelist_t *free } +/* FIXME: remove vgetargs1() to reuse vgetstack1(), need to take care of + * COMPAT...*/ +static int +vgetstack1(PyObject **stack, Py_ssize_t len, const char *format, va_list *p_va, int flags) +{ + char msgbuf[256]; + int levels[32]; + const char *fname = NULL; + const char *message = NULL; + int min = -1; + int max = 0; + int level = 0; + int endfmt = 0; + const char *formatsave = format; + Py_ssize_t i; + const char *msg; + int compat = flags & FLAG_COMPAT; + freelistentry_t static_entries[STATIC_FREELIST_ENTRIES]; + freelist_t freelist; + + freelist.entries = static_entries; + freelist.first_available = 0; + freelist.entries_malloced = 0; + + assert(!compat); + assert(stack != NULL || len == 0); + flags = flags & ~FLAG_COMPAT; + + while (endfmt == 0) { + int c = *format++; + switch (c) { + case '(': + if (level == 0) + max++; + level++; + if (level >= 30) + Py_FatalError("too many tuple nesting levels " + "in argument format string"); + break; + case ')': + if (level == 0) + Py_FatalError("excess ')' in getargs format"); + else + level--; + break; + case '\0': + endfmt = 1; + break; + case ':': + fname = format; + endfmt = 1; + break; + case ';': + message = format; + endfmt = 1; + break; + case '|': + if (level == 0) + min = max; + break; + default: + if (level == 0) { + if (Py_ISALPHA(Py_CHARMASK(c))) + if (c != 'e') /* skip encoded */ + max++; + } + break; + } + } + + if (level != 0) + Py_FatalError(/* '(' */ "missing ')' in getargs format"); + + if (min < 0) + min = max; + + format = formatsave; + + if (max > STATIC_FREELIST_ENTRIES) { + freelist.entries = PyMem_NEW(freelistentry_t, max); + if (freelist.entries == NULL) { + PyErr_NoMemory(); + return 0; + } + freelist.entries_malloced = 1; + } + + if (len < min || max < len) { + if (message == NULL) + PyErr_Format(PyExc_TypeError, + "%.150s%s takes %s %d argument%s (%ld given)", + fname==NULL ? "function" : fname, + fname==NULL ? "" : "()", + min==max ? "exactly" + : len < min ? "at least" : "at most", + len < min ? min : max, + (len < min ? min : max) == 1 ? "" : "s", + Py_SAFE_DOWNCAST(len, Py_ssize_t, long)); + else + PyErr_SetString(PyExc_TypeError, message); + return cleanreturn(0, &freelist); + } + + for (i = 0; i < len; i++) { + if (*format == '|') + format++; + msg = convertitem(stack[i], &format, p_va, + flags, levels, msgbuf, + sizeof(msgbuf), &freelist); + if (msg) { + seterror(i+1, msg, levels, fname, message); + return cleanreturn(0, &freelist); + } + } + + if (*format != '\0' && !Py_ISALPHA(Py_CHARMASK(*format)) && + *format != '(' && + *format != '|' && *format != ':' && *format != ';') { + PyErr_Format(PyExc_SystemError, + "bad format string: %.200s", formatsave); + return cleanreturn(0, &freelist); + } + + return cleanreturn(1, &freelist); +} + static int vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags) { @@ -1369,6 +1522,56 @@ int int +PyArg_ParseStackAndKeywords(PyObject **stack, Py_ssize_t nargs, + PyObject *keywords, + const char *format, + char **kwlist, ...) +{ + int retval; + va_list va; + + if ((stack == NULL && nargs != 0) || + (keywords != NULL && !PyDict_Check(keywords)) || + format == NULL || + kwlist == NULL) + { + PyErr_BadInternalCall(); + return 0; + } + + va_start(va, kwlist); + retval = vgetstackkeywords(stack, nargs, keywords, format, kwlist, &va, 0); + va_end(va); + return retval; +} + +int +_PyArg_ParseStackAndKeywords_SizeT(PyObject **stack, Py_ssize_t nargs, + PyObject *keywords, + const char *format, + char **kwlist, ...) +{ + int retval; + va_list va; + + if (stack == NULL || + (keywords != NULL && !PyDict_Check(keywords)) || + format == NULL || + kwlist == NULL) + { + PyErr_BadInternalCall(); + return 0; + } + + va_start(va, kwlist); + retval = vgetstackkeywords(stack, nargs, keywords, format, + kwlist, &va, FLAG_SIZE_T); + va_end(va); + return retval; +} + + +int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *keywords, const char *format, @@ -1435,8 +1638,8 @@ PyArg_ValidateKeywordArguments(PyObject #define IS_END_OF_FORMAT(c) (c == '\0' || c == ';' || c == ':') static int -vgetargskeywords(PyObject *args, PyObject *keywords, const char *format, - char **kwlist, va_list *p_va, int flags) +vgetstackkeywords(PyObject **stack, Py_ssize_t nargs, PyObject *keywords, const char *format, + char **kwlist, va_list *p_va, int flags) { char msgbuf[512]; int levels[32]; @@ -1444,7 +1647,7 @@ vgetargskeywords(PyObject *args, PyObjec int min = INT_MAX; int max = INT_MAX; int i, len; - Py_ssize_t nargs, nkeywords; + Py_ssize_t nkeywords; PyObject *current_arg; freelistentry_t static_entries[STATIC_FREELIST_ENTRIES]; freelist_t freelist; @@ -1453,7 +1656,6 @@ vgetargskeywords(PyObject *args, PyObjec freelist.first_available = 0; freelist.entries_malloced = 0; - assert(args != NULL && PyTuple_Check(args)); assert(keywords == NULL || PyDict_Check(keywords)); assert(format != NULL); assert(kwlist != NULL); @@ -1484,7 +1686,6 @@ vgetargskeywords(PyObject *args, PyObjec freelist.entries_malloced = 1; } - nargs = PyTuple_GET_SIZE(args); nkeywords = (keywords == NULL) ? 0 : PyDict_Size(keywords); if (nargs + nkeywords > len) { PyErr_Format(PyExc_TypeError, @@ -1559,7 +1760,7 @@ vgetargskeywords(PyObject *args, PyObjec else if (nkeywords && PyErr_Occurred()) return cleanreturn(0, &freelist); else if (i < nargs) - current_arg = PyTuple_GET_ITEM(args, i); + current_arg = stack[i]; if (current_arg) { msg = convertitem(current_arg, &format, p_va, flags, @@ -1631,6 +1832,20 @@ vgetargskeywords(PyObject *args, PyObjec return cleanreturn(1, &freelist); } +static int +vgetargskeywords(PyObject *args, PyObject *keywords, const char *format, + char **kwlist, va_list *p_va, int flags) +{ + PyObject **stack; + Py_ssize_t na; + + assert(args != NULL && PyTuple_Check(args)); + + stack = ((PyTupleObject *)args)->ob_item; + na = PyTuple_GET_SIZE(args); + return vgetstackkeywords(stack, na, keywords, format, kwlist, p_va, flags); +} + static const char * skipitem(const char **p_format, va_list *p_va, int flags) @@ -1754,21 +1969,14 @@ err: } -int -PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...) +static int +PyArg_VaUnpackStack(PyObject **stack, Py_ssize_t l, const char *name, Py_ssize_t min, Py_ssize_t max, va_list vargs) { - Py_ssize_t i, l; + Py_ssize_t i; PyObject **o; - va_list vargs; assert(min >= 0); assert(min <= max); - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, - "PyArg_UnpackTuple() argument list is not a tuple"); - return 0; - } - l = PyTuple_GET_SIZE(args); if (l < min) { if (name != NULL) PyErr_Format( @@ -1800,17 +2008,53 @@ PyArg_UnpackTuple(PyObject *args, const return 0; } + for (i = 0; i < l; i++) { + o = va_arg(vargs, PyObject **); + *o = stack[i]; + } + return 1; +} + +int +PyArg_UnpackStack(PyObject **stack, Py_ssize_t l, const char *name, Py_ssize_t min, Py_ssize_t max, ...) +{ + int retval; + va_list vargs; + #ifdef HAVE_STDARG_PROTOTYPES va_start(vargs, max); #else va_start(vargs); #endif - for (i = 0; i < l; i++) { - o = va_arg(vargs, PyObject **); - *o = PyTuple_GET_ITEM(args, i); + retval = PyArg_VaUnpackStack(stack, l, name, min, max, vargs); + va_end(vargs); + return retval; +} + +int +PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...) +{ + int retval; + va_list vargs; + PyObject **stack; + Py_ssize_t l; + + if (!PyTuple_Check(args)) { + PyErr_SetString(PyExc_SystemError, + "PyArg_UnpackTuple() argument list is not a tuple"); + return 0; } + stack = ((PyTupleObject *)args)->ob_item; + l = PyTuple_GET_SIZE(args); + +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, max); +#else + va_start(vargs); +#endif + retval = PyArg_VaUnpackStack(stack, l, name, min, max, vargs); va_end(vargs); - return 1; + return retval; } diff -r 496e094f4734 -r 34456cce64bb Python/import.c --- a/Python/import.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/import.c Thu May 19 13:47:42 2016 +0200 @@ -1639,31 +1639,28 @@ PyImport_ImportModuleLevelObject(PyObjec if (has_from < 0) goto error; if (!has_from) { - if (level == 0 || PyUnicode_GET_LENGTH(name) > 0) { - PyObject *front = NULL; - PyObject *partition = NULL; - PyObject *borrowed_dot = _PyUnicode_FromId(&single_dot); + Py_ssize_t len; + len = PyUnicode_GET_LENGTH(name); + if (level == 0 || len > 0) { + PyObject *front; + Py_ssize_t dot; - if (borrowed_dot == NULL) { + dot = PyUnicode_FindChar(name, '.', 0, len, 1); + if (dot == -2) { goto error; } - partition = PyUnicode_Partition(name, borrowed_dot); - if (partition == NULL) { - goto error; - } - - if (PyUnicode_GET_LENGTH(PyTuple_GET_ITEM(partition, 1)) == 0) { + if (dot == -1) { /* No dot in module name, simple exit */ - Py_DECREF(partition); final_mod = mod; Py_INCREF(mod); goto error; } - front = PyTuple_GET_ITEM(partition, 0); - Py_INCREF(front); - Py_DECREF(partition); + front = PyUnicode_Substring(name, 0, dot); + if (front == NULL) { + goto error; + } if (level == 0) { final_mod = PyObject_CallFunctionObjArgs(builtins_import, front, NULL); diff -r 496e094f4734 -r 34456cce64bb Python/modsupport.c --- a/Python/modsupport.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/modsupport.c Thu May 19 13:47:42 2016 +0200 @@ -148,6 +148,47 @@ do_mklist(const char **p_format, va_list return v; } +static int +do_mkstack(PyObject **stack, const char **p_format, va_list *p_va, int endchar, int n, int flags) +{ + int i; + int itemfailed = 0; + + /* Note that we can't bail immediately on error as this will leak + refcounts on any 'N' arguments. */ + for (i = 0; i < n; i++) { + PyObject *w; + + if (itemfailed) { + PyObject *exception, *value, *tb; + PyErr_Fetch(&exception, &value, &tb); + w = do_mkvalue(p_format, p_va, flags); + PyErr_Restore(exception, value, tb); + } + else { + w = do_mkvalue(p_format, p_va, flags); + } + if (w == NULL) { + itemfailed = 1; + Py_INCREF(Py_None); + w = Py_None; + } + stack[i] = w; + } + if (itemfailed) { + /* do_mkvalue() should have already set an error */ + return -1; + } + if (**p_format != endchar) { + PyErr_SetString(PyExc_SystemError, + "Unmatched paren in format"); + return -1; + } + if (endchar) + ++*p_format; + return 0; +} + static PyObject * do_mktuple(const char **p_format, va_list *p_va, int endchar, int n, int flags) { @@ -445,6 +486,171 @@ PyObject * return va_build_value(format, va, FLAG_SIZE_T); } +static const char* +format_strip_parenthesis(const char *format, char **p_copy) +{ + size_t len; + char *copy; + + *p_copy = NULL; + + /* FIXME: pass a flag to Py_VaBuildStack? */ + if (format[0] != '(') { + return format; + } + + len = strlen(format); + if (format[len-1] != ')') { + return format; + } + + /* Replace "(OO)" with "OO" */ + copy = PyMem_Malloc(len - 2 + 1); + if (copy == NULL) { + PyErr_NoMemory(); + return NULL; + } + Py_MEMCPY(copy, format + 1, len - 2); + copy[len-2] = '\0'; + + *p_copy = copy; + return copy; +} + +PyObject** +tuple_to_stack(PyObject *tuple, int *na) +{ + Py_ssize_t len = PyTuple_GET_SIZE(tuple); + Py_ssize_t i; + PyObject **stack; + + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, "too many parameters"); + return NULL; + } + + stack = PyMem_Malloc(len * sizeof(stack[0])); + if (stack == NULL) { + PyErr_NoMemory(); + return NULL; + } + + for (i=0; i < len; i++) { + PyObject *obj = PyTuple_GET_ITEM(tuple, i); + Py_INCREF(obj); + stack[i] = obj; + } + /* overflow tested below */ + *na = (int)len; + return stack; +} + +PyObject** +va_build_stack(PyObject **small_stack, Py_ssize_t small_stack_len, + int *p_na, const char *format, va_list va, int flags) +{ + const char *f; + int n; + va_list lva; + char *copy; + int stripped; + PyObject **stack; + + if (format == NULL || *format == '\0') { + *p_na = 0; + return small_stack; + } + + f = format_strip_parenthesis(format, ©); + if (f == NULL) { + return NULL; + } + stripped = (copy != NULL); + + n = countformat(f, '\0'); + + Py_VA_COPY(lva, va); + + if (n < 0) { + PyMem_Free(copy); + return NULL; + } + + stack = _PyStack_Alloc(small_stack, small_stack_len, n); + if (stack == NULL) { + return NULL; + } + + if (do_mkstack(stack, &f, &lva, '\0', n, flags) < 0) { + PyMem_Free(copy); + _PyStack_Free(stack, small_stack, n); + return NULL; + } + PyMem_Free(copy); + + if (stack == NULL) { + return NULL; + } + + /* if format isn't "(...)" and stack only contains one object which is a + tuple: unpack the tuple to a new stack */ + if (n == 1 && !stripped && PyTuple_Check(stack[0])) { + PyObject **stack2; + int n2; + + stack2 = tuple_to_stack(stack[0], &n2); + _PyStack_Free(stack, small_stack, n); + if (stack2 == NULL) { + return NULL; + } + + stack = stack2; + n = n2; + } + + *p_na = n; + return stack; +} + +PyObject** +Py_VaBuildStack(PyObject **small_stack, Py_ssize_t small_stack_len, + int *p_na, const char *format, va_list va) +{ + return va_build_stack(small_stack, small_stack_len, p_na, format, va, 0); +} + +PyObject** +_Py_VaBuildStack_SizeT(PyObject **small_stack, Py_ssize_t small_stack_len, + int *p_na, const char *format, va_list va) +{ + return va_build_stack(small_stack, small_stack_len, p_na, format, va, FLAG_SIZE_T); +} + +PyObject** +Py_BuildStack(PyObject **small_stack, Py_ssize_t small_stack_len, int *p_na, + const char *format, ...) +{ + va_list va; + PyObject **stack; + va_start(va, format); + stack = va_build_stack(small_stack, small_stack_len, p_na, format, va, 0); + va_end(va); + return stack; +} + +PyObject** +_Py_BuildStack_SizeT(PyObject **small_stack, Py_ssize_t small_stack_len, int *p_na, + const char *format, ...) +{ + va_list va; + PyObject **stack; + va_start(va, format); + stack = va_build_stack(small_stack, small_stack_len, p_na, format, va, FLAG_SIZE_T); + va_end(va); + return stack; +} + + static PyObject * va_build_value(const char *format, va_list va, int flags) { @@ -452,7 +658,7 @@ va_build_value(const char *format, va_li int n = countformat(f, '\0'); va_list lva; - Py_VA_COPY(lva, va); + Py_VA_COPY(lva, va); if (n < 0) return NULL; @@ -470,21 +676,13 @@ PyObject * PyEval_CallFunction(PyObject *obj, const char *format, ...) { va_list vargs; - PyObject *args; - PyObject *res; + PyObject *result; va_start(vargs, format); - - args = Py_VaBuildValue(format, vargs); + result = _PyObject_CallVaFunction(obj, format, vargs); va_end(vargs); - if (args == NULL) - return NULL; - - res = PyEval_CallObject(obj, args); - Py_DECREF(args); - - return res; + return result; } @@ -492,29 +690,13 @@ PyObject * PyEval_CallMethod(PyObject *obj, const char *methodname, const char *format, ...) { va_list vargs; - PyObject *meth; - PyObject *args; - PyObject *res; - - meth = PyObject_GetAttrString(obj, methodname); - if (meth == NULL) - return NULL; + PyObject *result; va_start(vargs, format); - - args = Py_VaBuildValue(format, vargs); + result = _PyObject_CallVaMethod(obj, methodname, 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; + return result; } int diff -r 496e094f4734 -r 34456cce64bb Python/pystack.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/pystack.c Thu May 19 13:47:42 2016 +0200 @@ -0,0 +1,288 @@ +#include "Python.h" + +PyObject** +_PyStack_FromBorrowedTuple(PyObject *args, Py_ssize_t start, int *p_nargs) +{ + Py_ssize_t len; + + assert(start >= 0); + + if (args != NULL) { + assert(PyTuple_Check(args)); + + len = PyTuple_GET_SIZE(args); + if (len <= start) { + *p_nargs = 0; + return NULL; + } + len -= start; + + assert(len <= INT_MAX); + *p_nargs = (int)len; + + return &((PyTupleObject *)args)->ob_item[start]; + } + else { + *p_nargs = 0; + return NULL; + } +} + +PyObject** +_PyStack_Copy(PyObject **small_stack, Py_ssize_t small_stack_len, + PyObject **stack, int nargs) +{ + PyObject **stack2; + int i; + + stack2 = _PyStack_Alloc(small_stack, small_stack_len, nargs); + if (stack2 == NULL) { + return NULL; + } + + for (i=0; i < nargs; i++) { + PyObject *obj = stack[i]; + Py_INCREF(obj); + stack2[i] = obj; + } + + return stack2; +} + +PyObject** +_PyStack_FromVa(PyObject **small_stack, Py_ssize_t small_stack_len, + va_list va, int *p_na) +{ + va_list countva; + PyObject **stack; + Py_ssize_t nargs; + + Py_VA_COPY(countva, va); + + nargs = 0; + while (1) { + PyObject *obj = (PyObject *)va_arg(countva, PyObject *); + if (obj == NULL) + break; + nargs++; + } + + if (nargs > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, "too many arguments"); + return NULL; + } + + stack = _PyStack_Alloc(small_stack, small_stack_len, nargs); + if (stack == NULL) { + return NULL; + } + + for (Py_ssize_t i = 0; i < nargs; ++i) { + PyObject *obj = (PyObject *)va_arg(va, PyObject *); + /* FIXME: does it matter to keep a strong reference? */ + Py_INCREF(obj); + stack[i] = obj; + } + + /* check for overflow above */ + *p_na = (int)nargs; + return stack; +} + +PyObject** +_PyStack_PrependArg(PyObject **stack, int nargs, + PyObject **small_stack, Py_ssize_t small_stack_len, + PyObject *arg) +{ + PyObject **stack2; + + stack2 = _PyStack_Alloc(small_stack, small_stack_len, 1 + nargs); + if (stack2 == NULL) { + return NULL; + } + + Py_INCREF(arg); + stack2[0] = arg; + + for (Py_ssize_t i = 0; i < nargs; i++) { + PyObject *obj = stack[i]; + Py_INCREF(obj); + stack2[i+1] = obj; + } + return stack2; +} + +PyObject** +_PyStack_FromTuple(PyObject **small_stack, Py_ssize_t small_stack_len, + PyObject *tuple, int *p_na) +{ + PyObject **stack; + Py_ssize_t nargs, i; + + assert(PyTuple_Check(tuple)); + + nargs = PyTuple_GET_SIZE(tuple); + if (nargs > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, "too many arguments"); + *p_na = 0; + return NULL; + } + + stack = _PyStack_Alloc(small_stack, small_stack_len, nargs); + if (stack == NULL) { + *p_na = 0; + return NULL; + } + + for (i = 0; i < nargs; ++i) { + PyObject *item = PyTuple_GET_ITEM(tuple, i); + Py_INCREF(item); + stack[i] = item; + } + + /* downcas is safe, checked for integer overflow above */ + *p_na = (int)nargs; + return stack; +} + + +PyObject** +_PyStack_Alloc(PyObject **small_stack, Py_ssize_t small_stack_len, + Py_ssize_t nargs) +{ + PyObject **stack; + + if (nargs <= small_stack_len) { + return small_stack; + } + + if (nargs > PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(PyObject *)) { + PyErr_NoMemory(); + return NULL; + } + + stack = PyMem_Malloc(nargs * sizeof(PyObject *)); + if (stack == NULL) { + PyErr_NoMemory(); + return NULL; + } + return stack; +} + +void +_PyStack_Free(PyObject **stack, PyObject **small_stack, + Py_ssize_t nargs) +{ + for (Py_ssize_t i = 0; i < nargs; i++) { + Py_DECREF(stack[i]); + } + if (stack != small_stack) { + PyMem_Free(stack); + } +} + + +PyObject* +_PyStack_AsTupleSlice(PyObject **stack, Py_ssize_t nargs, + Py_ssize_t start, Py_ssize_t end) +{ + PyObject *args; + Py_ssize_t src, dst, len; + + assert(start >= 0); + assert(end <= nargs); + + len = end - start; + + args = PyTuple_New(len); + if (args == NULL) { + return NULL; + } + + for (src=start, dst=0; src < end; src++, dst++) { + PyObject *item = stack[src]; + Py_INCREF(item); + PyTuple_SET_ITEM(args, dst, item); + } + + return args; +} + +PyObject* +_PyStack_AsTuple(PyObject **stack, Py_ssize_t nargs) +{ + return _PyStack_AsTupleSlice(stack, nargs, 0, nargs); +} + +int +pystack_chekargs(PyObject **stack, Py_ssize_t nargs, Py_ssize_t nk, + const char *func_name, + Py_ssize_t min_na, Py_ssize_t max_na) +{ + if (nargs < min_na) { + PyErr_Format(PyExc_TypeError, + "%s() takes at least %d argument%s (%zd given)", + func_name, + min_na, + (min_na == 1) ? "" : "s", + nargs + nk); + return -1; + } + + if (nargs > max_na) { + PyErr_Format(PyExc_TypeError, + "%s() takes at most %d argument%s (%zd given)", + func_name, + max_na, + (max_na == 1) ? "" : "s", + nargs + nk); + return -1; + } + return 0; +} + +int +_PyStack_CheckArgs(PyObject **stack, Py_ssize_t nargs, PyObject *kwargs, + const char *func_name, + Py_ssize_t min_na, Py_ssize_t max_na) +{ + Py_ssize_t nk; + + if (kwargs != NULL) { + assert(PyDict_Check(kwargs)); + nk = PyDict_Size(kwargs); + } + else { + nk = 0; + } + + if (pystack_chekargs(stack, nargs, nk, func_name, min_na, max_na) < 0) { + return -1; + } + + if (nk != 0) { + PyErr_Format(PyExc_TypeError, + "%s() does not take keyword arguments", + func_name); + return -1; + } + return 0; +} + +int +_PyStack_CheckArgsKeywords(PyObject **stack, Py_ssize_t nargs, PyObject *kwargs, + const char *func_name, + Py_ssize_t min_na, Py_ssize_t max_na) +{ + Py_ssize_t nk; + + if (kwargs != NULL) { + assert(PyDict_Check(kwargs)); + nk = PyDict_Size(kwargs); + } + else { + nk = 0; + } + + return pystack_chekargs(stack, nargs, nk, func_name, min_na, max_na); +} diff -r 496e094f4734 -r 34456cce64bb Python/pythonrun.c --- a/Python/pythonrun.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/pythonrun.c Thu May 19 13:47:42 2016 +0200 @@ -630,8 +630,13 @@ PyErr_PrintEx(int set_sys_last_vars) } hook = _PySys_GetObjectId(&PyId_excepthook); if (hook) { - PyObject *args = PyTuple_Pack(3, exception, v, tb); - PyObject *result = PyEval_CallObject(hook, args); + PyObject* stack[3]; + PyObject *result; + + stack[0] = exception; + stack[1] = v; + stack[2] = tb; + result = _PyObject_FastCall(hook, stack, 3, NULL); if (result == NULL) { PyObject *exception2, *v2, *tb2; if (PyErr_ExceptionMatches(PyExc_SystemExit)) { @@ -660,7 +665,6 @@ PyErr_PrintEx(int set_sys_last_vars) Py_XDECREF(tb2); } Py_XDECREF(result); - Py_XDECREF(args); } else { PySys_WriteStderr("sys.excepthook is missing\n"); PyErr_Display(exception, v, tb); diff -r 496e094f4734 -r 34456cce64bb Python/sysmodule.c --- a/Python/sysmodule.c Thu Apr 21 00:23:08 2016 -0700 +++ b/Python/sysmodule.c Thu May 19 13:47:42 2016 +0200 @@ -368,34 +368,23 @@ static PyObject * call_trampoline(PyObject* callback, PyFrameObject *frame, int what, PyObject *arg) { - PyObject *args; - PyObject *whatstr; + PyObject *stack[3]; PyObject *result; - args = PyTuple_New(3); - if (args == NULL) - return NULL; if (PyFrame_FastToLocalsWithError(frame) < 0) return NULL; - Py_INCREF(frame); - whatstr = whatstrings[what]; - Py_INCREF(whatstr); - if (arg == NULL) - arg = Py_None; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, (PyObject *)frame); - PyTuple_SET_ITEM(args, 1, whatstr); - PyTuple_SET_ITEM(args, 2, arg); + stack[0] = (PyObject *)frame; + stack[1] = whatstrings[what]; + stack[2] = (arg != NULL) ? arg : Py_None; /* call the Python-level function */ - result = PyEval_CallObject(callback, args); + result = _PyObject_FastCall(callback, stack, 3, NULL); + PyFrame_LocalsToFast(frame, 1); if (result == NULL) PyTraceBack_Here(frame); - /* cleanup */ - Py_DECREF(args); return result; } @@ -2111,7 +2100,7 @@ PySys_SetArgv(int argc, wchar_t **argv) static int sys_pyfile_write_unicode(PyObject *unicode, PyObject *file) { - PyObject *writer = NULL, *args = NULL, *result = NULL; + PyObject *writer = NULL, *result = NULL; int err; if (file == NULL) @@ -2121,11 +2110,7 @@ sys_pyfile_write_unicode(PyObject *unico if (writer == NULL) goto error; - args = PyTuple_Pack(1, unicode); - if (args == NULL) - goto error; - - result = PyEval_CallObject(writer, args); + result = PyObject_CallArg1(writer, unicode); if (result == NULL) { goto error; } else { @@ -2137,7 +2122,6 @@ error: err = -1; finally: Py_XDECREF(writer); - Py_XDECREF(args); Py_XDECREF(result); return err; } diff -r 496e094f4734 -r 34456cce64bb Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py Thu Apr 21 00:23:08 2016 -0700 +++ b/Tools/clinic/clinic.py Thu May 19 13:47:42 2016 +0200 @@ -698,6 +698,11 @@ class CLanguage(Language): {c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs) """) + parser_prototype_fastcall = normalize_snippet(""" + static PyObject * + {c_basename}({self_type}{self_name}, PyObject **stack, int nargs, PyObject *kwargs) + """) + parser_prototype_varargs = normalize_snippet(""" static PyObject * {c_basename}({self_type}{self_name}, PyObject *args) @@ -809,46 +814,90 @@ class CLanguage(Language): # and nothing but normal objects: # PyArg_UnpackTuple! - flags = "METH_VARARGS" - parser_prototype = parser_prototype_varargs - - parser_definition = parser_body(parser_prototype, normalize_snippet(""" - if (!PyArg_UnpackTuple(args, "{name}", - {unpack_min}, {unpack_max}, - {parse_arguments})) - goto exit; - """, indent=4)) + if not new_or_init: + flags = "METH_FASTCALL" + parser_prototype = parser_prototype_fastcall + + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!PyArg_UnpackStack(stack, nargs, "{name}", + {unpack_min}, {unpack_max}, + {parse_arguments})) + goto exit; + if ({self_type_check}!_PyArg_NoKeywords("{name}", kwargs)) + goto exit; + """, indent=4)) + else: + flags = "METH_VARARGS" + parser_prototype = parser_prototype_varargs + + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!PyArg_UnpackTuple(args, "{name}", + {unpack_min}, {unpack_max}, + {parse_arguments})) + goto exit; + """, indent=4)) elif positional: # positional-only, but no option groups # we only need one call to PyArg_ParseTuple - flags = "METH_VARARGS" - parser_prototype = parser_prototype_varargs - - parser_definition = parser_body(parser_prototype, normalize_snippet(""" - if (!PyArg_ParseTuple(args, "{format_units}:{name}", - {parse_arguments})) - goto exit; - """, indent=4)) + if not new_or_init: + flags = "METH_FASTCALL" + parser_prototype = parser_prototype_fastcall + + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!PyArg_ParseStack(stack, nargs, "{format_units}:{name}", + {parse_arguments})) + goto exit; + if (!_PyArg_NoKeywords("{name}()", kwargs)) + goto exit; + """, indent=4)) + else: + flags = "METH_VARARGS" + parser_prototype = parser_prototype_varargs + + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!PyArg_ParseTuple(args, "{format_units}:{name}", + {parse_arguments})) + goto exit; + """, indent=4)) else: - # positional-or-keyword arguments - flags = "METH_VARARGS|METH_KEYWORDS" - - parser_prototype = parser_prototype_keyword - - body = normalize_snippet(""" - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords, - {parse_arguments})) - goto exit; - """, indent=4) - parser_definition = parser_body(parser_prototype, normalize_snippet(""" - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords, - {parse_arguments})) - goto exit; - """, indent=4)) - parser_definition = insert_keywords(parser_definition) + if not new_or_init: + # positional-or-keyword arguments + flags = "METH_FASTCALL" + + parser_prototype = parser_prototype_fastcall + + body = normalize_snippet(""" + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "{format_units}:{name}", _keywords, + {parse_arguments})) + goto exit; + """, indent=4) + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!PyArg_ParseStackAndKeywords(stack, nargs, kwargs, "{format_units}:{name}", _keywords, + {parse_arguments})) + goto exit; + """, indent=4)) + parser_definition = insert_keywords(parser_definition) + else: + # positional-or-keyword arguments + flags = "METH_VARARGS|METH_KEYWORDS" + + + parser_prototype = parser_prototype_keyword + + body = normalize_snippet(""" + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords, + {parse_arguments})) + goto exit; + """, indent=4) + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords, + {parse_arguments})) + goto exit; + """, indent=4)) + parser_definition = insert_keywords(parser_definition) if new_or_init: