@@ -2004,12 +2004,8 @@ def generate(self, code_sink, module):
2004
2004
'PyModule_AddObject(m, (char *) \" %s\" , (PyObject *) _TYPEREF %s);' % (
2005
2005
class_python_name , self .pytypestruct ))
2006
2006
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\" , _TYPEREF %s);\n '
2008
+ % (
2013
2009
self .outer_class .pytypestruct , class_python_name , self .pytypestruct ))
2014
2010
2015
2011
have_constructor = self ._generate_constructor (code_sink )
@@ -2578,12 +2574,7 @@ def _generate_destructor(self, code_sink, have_constructor):
2578
2574
else :
2579
2575
code_block .write_code (self ._get_delete_code ())
2580
2576
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 ' )
2577
+ code_block .write_code (' PyObject_DEL(self);\n ' )
2587
2578
2588
2579
code_block .write_cleanup ()
2589
2580
0 commit comments