Skip to content

Commit 97e1568

Browse files
authored
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.
1 parent a15c9b3 commit 97e1568

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Tools/clinic/clinic.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def output_templates(self, f):
724724

725725
parser_prototype_def_class = normalize_snippet("""
726726
static PyObject *
727-
{c_basename}({self_type}{self_name}, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
727+
{c_basename}({self_type}{self_name}, PyTypeObject *{defining_class_name}, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
728728
""")
729729

730730
# parser_body_fields remembers the fields passed in to the
@@ -1305,7 +1305,8 @@ def render_function(self, clinic, f):
13051305
template_dict['docstring'] = self.docstring_for_c_string(f)
13061306

13071307
template_dict['self_name'] = template_dict['self_type'] = template_dict['self_type_check'] = ''
1308-
f_self.converter.set_template_dict(template_dict)
1308+
for converter in converters:
1309+
converter.set_template_dict(template_dict)
13091310

13101311
f.return_converter.render(f, data)
13111312
template_dict['impl_return_type'] = f.return_converter.type
@@ -2698,6 +2699,10 @@ def parse_arg(self, argname, displayname):
26982699
""".format(argname=argname, paramname=self.name, cast=cast)
26992700
return None
27002701

2702+
def set_template_dict(self, template_dict):
2703+
pass
2704+
2705+
27012706
type_checks = {
27022707
'&PyLong_Type': ('PyLong_Check', 'int'),
27032708
'&PyTuple_Type': ('PyTuple_Check', 'tuple'),

0 commit comments

Comments
 (0)