mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
bpo-1635741: _ast uses PyModule_AddObjectRef() (GH-23146)
Replace PyModule_AddObject() with PyModule_AddObjectRef() in the _ast module (Python-ast.c).
This commit is contained in:
parent
988f1ec8d2
commit
18ce7f1d0a
2 changed files with 209 additions and 312 deletions
|
@ -1115,10 +1115,9 @@ class ASTModuleVisitor(PickleVisitor):
|
|||
self.emit('if (state == NULL) {', 1)
|
||||
self.emit('return -1;', 2)
|
||||
self.emit('}', 1)
|
||||
self.emit('if (PyModule_AddObject(m, "AST", state->AST_type) < 0) {', 1)
|
||||
self.emit('if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {', 1)
|
||||
self.emit('return -1;', 2)
|
||||
self.emit('}', 1)
|
||||
self.emit('Py_INCREF(state->AST_type);', 1)
|
||||
self.emit('if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {', 1)
|
||||
self.emit("return -1;", 2)
|
||||
self.emit('}', 1)
|
||||
|
@ -1166,11 +1165,10 @@ PyInit__ast(void)
|
|||
self.addObj(cons.name)
|
||||
|
||||
def addObj(self, name):
|
||||
self.emit("if (PyModule_AddObject(m, \"%s\", "
|
||||
self.emit("if (PyModule_AddObjectRef(m, \"%s\", "
|
||||
"state->%s_type) < 0) {" % (name, name), 1)
|
||||
self.emit("return -1;", 2)
|
||||
self.emit('}', 1)
|
||||
self.emit("Py_INCREF(state->%s_type);" % name, 1)
|
||||
|
||||
|
||||
class StaticVisitor(PickleVisitor):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue