bpo-39573: Update clinic to use Py_IS_TYPE() function (GH-18507)

This commit is contained in:
Dong-hee Na 2020-02-14 16:50:19 +09:00 • committed by GitHub
parent d212c3c55d
commit 9aeb0ef930
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 16 deletions

View file

@ -3585,17 +3585,14 @@ class self_converter(CConverter):
cls = self.function.cls
if ((kind in (METHOD_NEW, METHOD_INIT)) and cls and cls.typedef):
type_object = self.function.cls.type_object
if kind == METHOD_NEW:
passed_in_type = self.name
type_check = '({} == {})'.format(self.name, type_object)
else:
passed_in_type = 'Py_TYPE({})'.format(self.name)
type_check = 'Py_IS_TYPE({}, {})'.format(self.name, type_object)
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)
line = '{} &&\n '.format(type_check)
template_dict['self_type_check'] = line