@@ -1115,10 +1115,9 @@ def visitModule(self, mod):
11151115 self .emit ('if (state == NULL) {' , 1 )
11161116 self .emit ('return -1;' , 2 )
11171117 self .emit ('}' , 1 )
1118- self .emit ('if (PyModule_AddObject (m, "AST", state->AST_type) < 0) {' , 1 )
1118+ self .emit ('if (PyModule_AddObjectRef (m, "AST", state->AST_type) < 0) {' , 1 )
11191119 self .emit ('return -1;' , 2 )
11201120 self .emit ('}' , 1 )
1121- self .emit ('Py_INCREF(state->AST_type);' , 1 )
11221121 self .emit ('if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {' , 1 )
11231122 self .emit ("return -1;" , 2 )
11241123 self .emit ('}' , 1 )
@@ -1166,11 +1165,10 @@ def visitConstructor(self, cons, name):
11661165 self .addObj (cons .name )
11671166
11681167 def addObj (self , name ):
1169- self .emit ("if (PyModule_AddObject (m, \" %s\" , "
1168+ self .emit ("if (PyModule_AddObjectRef (m, \" %s\" , "
11701169 "state->%s_type) < 0) {" % (name , name ), 1 )
11711170 self .emit ("return -1;" , 2 )
11721171 self .emit ('}' , 1 )
1173- self .emit ("Py_INCREF(state->%s_type);" % name , 1 )
11741172
11751173
11761174class StaticVisitor (PickleVisitor ):
0 commit comments