diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-02-14 07:50:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-14 07:50:19 (GMT) |
commit | 9aeb0ef9309384099e2f23bcee2240fbc096568e (patch) | |
tree | 38b619f23a9ef0e5bb08231cd5f74683d76876b5 /Tools | |
parent | d212c3c55d414203b0579e000d9f340f8cd11be7 (diff) | |
download | cpython-9aeb0ef9309384099e2f23bcee2240fbc096568e.zip cpython-9aeb0ef9309384099e2f23bcee2240fbc096568e.tar.gz cpython-9aeb0ef9309384099e2f23bcee2240fbc096568e.tar.bz2 |
bpo-39573: Update clinic to use Py_IS_TYPE() function (GH-18507)
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/clinic/clinic.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index b503932..382e29a 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -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) - - 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) + type_check = 'Py_IS_TYPE({}, {})'.format(self.name, type_object) + + line = '{} &&\n '.format(type_check) + template_dict['self_type_check'] = line |