summaryrefslogtreecommitdiffstats
path: root/Tools/clinic
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-01-26 06:01:12 (GMT)
committerLarry Hastings <larry@hastings.org>2014-01-26 06:01:12 (GMT)
commitf0537e8d1c9f070d094425b9bf824756fc9498f8 (patch)
tree60d2fbde46ef3db39a0843c57344d6969cb8e440 /Tools/clinic
parent0711dd921bd49c3d88e3716c43f8842bcc70bab4 (diff)
downloadcpython-f0537e8d1c9f070d094425b9bf824756fc9498f8.zip
cpython-f0537e8d1c9f070d094425b9bf824756fc9498f8.tar.gz
cpython-f0537e8d1c9f070d094425b9bf824756fc9498f8.tar.bz2
Issue #20390: Final fix, for generating NoPositional/NoKeyword for __init__ calls.
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-xTools/clinic/clinic.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 184bb39..f3fe3c1 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -2593,11 +2593,21 @@ class self_converter(CConverter):
def set_template_dict(self, template_dict):
template_dict['self_name'] = self.name
template_dict['self_type'] = self.parser_type
- if ((self.function.kind == METHOD_NEW) and
- self.function.cls and
- self.function.cls.typedef):
- template_dict['self_type_object'] = self.function.cls.type_object
- template_dict['self_type_check'] = '({self_name} == {self_type_object}) &&\n '.format_map(template_dict)
+ kind = self.function.kind
+ cls = self.function.cls
+
+ if ((kind in (METHOD_NEW, METHOD_INIT)) and cls and cls.typedef):
+ if kind == METHOD_NEW:
+ passed_in_type = self.name
+ else:
+ passed_in_type = 'Py_TYPE({})'.format(self.name)
+
+ line = '({passed_in_type} == {type_object}) &&\n '
+ d = {
+ 'type_object': self.function.cls.type_object,
+ 'passed_in_type': passed_in_type
+ }
+ template_dict['self_type_check'] = line.format_map(d)