--- /dev/null
+Update clinic tool to use :c:func:`Py_IS_TYPE`. Patch by Dong-hee Na.
PyObject *writer;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
+ if (Py_IS_TYPE(self, &PyBufferedRWPair_Type) &&
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit;
}
exit:
return return_value;
}
-/*[clinic end generated code: output=7246104f6c7d3167 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7d9ad40c95bdd808 input=a9049054013a1b77]*/
int return_value = -1;
int compresslevel = 9;
- if ((Py_TYPE(self) == &BZ2Compressor_Type) &&
+ if (Py_IS_TYPE(self, &BZ2Compressor_Type) &&
!_PyArg_NoKeywords("BZ2Compressor", kwargs)) {
goto exit;
}
{
int return_value = -1;
- if ((Py_TYPE(self) == &BZ2Decompressor_Type) &&
+ if (Py_IS_TYPE(self, &BZ2Decompressor_Type) &&
!_PyArg_NoPositional("BZ2Decompressor", args)) {
goto exit;
}
- if ((Py_TYPE(self) == &BZ2Decompressor_Type) &&
+ if (Py_IS_TYPE(self, &BZ2Decompressor_Type) &&
!_PyArg_NoKeywords("BZ2Decompressor", kwargs)) {
goto exit;
}
exit:
return return_value;
}
-/*[clinic end generated code: output=ec3d1b3652c98823 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3f3f1e788fe28ee1 input=a9049054013a1b77]*/
int return_value = -1;
PyObject *iterable = NULL;
- if ((Py_TYPE(self) == &PyList_Type) &&
+ if (Py_IS_TYPE(self, &PyList_Type) &&
!_PyArg_NoKeywords("list", kwargs)) {
goto exit;
}
{
return list___reversed___impl(self);
}
-/*[clinic end generated code: output=73718c0c33798c62 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1ff61490c091d165 input=a9049054013a1b77]*/
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