diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2017-01-27 13:05:09 +0000 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2017-01-27 13:05:09 +0000 |
commit | d45d8652710e51576367db00b226b8465e6c5ce6 (patch) | |
tree | eeb12605abc98507852e82848382c2e739991708 /Tools/clinic/clinic.py | |
parent | 6ccbbb38caa79f9eb9b93b5767f3787fc80cbac1 (diff) | |
parent | bbbab3c96168cea9f872f90da0a385b50f62ca70 (diff) | |
download | cpython-d45d8652710e51576367db00b226b8465e6c5ce6.tar.gz |
Closes #28784: Merged update from 3.6.
Diffstat (limited to 'Tools/clinic/clinic.py')
-rwxr-xr-x | Tools/clinic/clinic.py | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 75ac673737..894d1c5d99 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -705,14 +705,14 @@ class CLanguage(Language): {c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs) """) - parser_prototype_fastcall = normalize_snippet(""" + parser_prototype_varargs = normalize_snippet(""" static PyObject * - {c_basename}({self_type}{self_name}, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) + {c_basename}({self_type}{self_name}, PyObject *args) """) - parser_prototype_varargs = normalize_snippet(""" + parser_prototype_fastcall = normalize_snippet(""" static PyObject * - {c_basename}({self_type}{self_name}, PyObject *args) + {c_basename}({self_type}{self_name}, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) """) # parser_body_fields remembers the fields passed in to the @@ -825,30 +825,64 @@ class CLanguage(Language): # and nothing but normal objects: # PyArg_UnpackTuple! - flags = "METH_VARARGS" - parser_prototype = parser_prototype_varargs + if not new_or_init: + flags = "METH_FASTCALL" + parser_prototype = parser_prototype_fastcall - parser_definition = parser_body(parser_prototype, normalize_snippet(""" - if (!PyArg_UnpackTuple(args, "{name}", - {unpack_min}, {unpack_max}, - {parse_arguments})) {{ - goto exit; - }} - """, indent=4)) + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!_PyArg_UnpackStack(args, nargs, "{name}", + {unpack_min}, {unpack_max}, + {parse_arguments})) {{ + goto exit; + }} + + if ({self_type_check}!_PyArg_NoStackKeywords("{name}", kwnames)) {{ + 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 + if not new_or_init: + # positional-only, but no option groups + # we only need one call to _PyArg_ParseStack - flags = "METH_VARARGS" - parser_prototype = parser_prototype_varargs + flags = "METH_FASTCALL" + parser_prototype = parser_prototype_fastcall - parser_definition = parser_body(parser_prototype, normalize_snippet(""" - if (!PyArg_ParseTuple(args, "{format_units}:{name}", - {parse_arguments})) {{ - goto exit; - }} - """, indent=4)) + parser_definition = parser_body(parser_prototype, normalize_snippet(""" + if (!_PyArg_ParseStack(args, nargs, "{format_units}:{name}", + {parse_arguments})) {{ + goto exit; + }} + + if ({self_type_check}!_PyArg_NoStackKeywords("{name}", kwnames)) {{ + goto exit; + }} + """, indent=4)) + else: + # 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)) elif not new_or_init: flags = "METH_FASTCALL" @@ -856,7 +890,7 @@ class CLanguage(Language): parser_prototype = parser_prototype_fastcall body = normalize_snippet(""" - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, {parse_arguments})) {{ goto exit; }} |