diff options
author | Victor Stinner <vstinner@python.org> | 2020-05-13 22:31:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 22:31:31 (GMT) |
commit | 97e1568325e4d8eff2fc80eeb174b3f3e5d1c350 (patch) | |
tree | 48c7935d9294fb3f1c3bea0cd58e3d7c8fbdb7e9 /Tools/clinic | |
parent | a15c9b3a0524e5ca0434d2ad11076677824af941 (diff) | |
download | cpython-97e1568325e4d8eff2fc80eeb174b3f3e5d1c350.zip cpython-97e1568325e4d8eff2fc80eeb174b3f3e5d1c350.tar.gz cpython-97e1568325e4d8eff2fc80eeb174b3f3e5d1c350.tar.bz2 |
bpo-38787: Fix Argument Clinic defining_class_converter (GH-20074)
Don't hardcode defining_class parameter name to "cls":
* Define CConverter.set_template_dict(): do nothing by default
* CLanguage.render_function() now calls set_template_dict() on all
converters.
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-x | Tools/clinic/clinic.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 281a749..b07ffdd 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -724,7 +724,7 @@ class CLanguage(Language): parser_prototype_def_class = normalize_snippet(""" static PyObject * - {c_basename}({self_type}{self_name}, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) + {c_basename}({self_type}{self_name}, PyTypeObject *{defining_class_name}, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) """) # parser_body_fields remembers the fields passed in to the @@ -1305,7 +1305,8 @@ class CLanguage(Language): template_dict['docstring'] = self.docstring_for_c_string(f) template_dict['self_name'] = template_dict['self_type'] = template_dict['self_type_check'] = '' - f_self.converter.set_template_dict(template_dict) + for converter in converters: + converter.set_template_dict(template_dict) f.return_converter.render(f, data) template_dict['impl_return_type'] = f.return_converter.type @@ -2698,6 +2699,10 @@ class CConverter(metaclass=CConverterAutoRegister): """.format(argname=argname, paramname=self.name, cast=cast) return None + def set_template_dict(self, template_dict): + pass + + type_checks = { '&PyLong_Type': ('PyLong_Check', 'int'), '&PyTuple_Type': ('PyTuple_Check', 'tuple'), |