@@ -2004,12 +2004,7 @@ def generate(self, code_sink, module):
20042004 'PyModule_AddObject(m, (char *) \" %s\" , (PyObject *) _TYPEREF %s);' % (
20052005 class_python_name , self .pytypestruct ))
20062006 else :
2007- module .after_init .write_code (
2008- '#ifdef Py_LIMITED_API\n '
2009- 'PyObject_SetAttrString((PyObject*) %s, (char *) \" %s\" , (PyObject *) %s);\n '
2010- '#else\n '
2011- 'PyDict_SetItemString((PyObject*) %s.tp_dict, \" %s\" , (PyObject *) &%s);\n '
2012- '#endif\n ' % (self .outer_class .pytypestruct , class_python_name , self .pytypestruct ,
2007+ module .after_init .write_code ('PBG_SETATTR(%s, \" %s\" , %s);\n ' % (
20132008 self .outer_class .pytypestruct , class_python_name , self .pytypestruct ))
20142009
20152010 have_constructor = self ._generate_constructor (code_sink )
@@ -2578,12 +2573,7 @@ def _generate_destructor(self, code_sink, have_constructor):
25782573 else :
25792574 code_block .write_code (self ._get_delete_code ())
25802575
2581- code_block .write_code (
2582- ' #ifdef Py_LIMITED_API\n '
2583- ' PyObject_DEL(self);\n '
2584- ' #else\n '
2585- ' Py_TYPE(self)->tp_free((PyObject*)self);\n '
2586- ' #endif\n ' )
2576+ code_block .write_code (' PyObject_DEL(self);\n ' )
25872577
25882578 code_block .write_cleanup ()
25892579
0 commit comments