summaryrefslogtreecommitdiffstats
path: root/Parser/asdl_c.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-11-04 15:37:07 (GMT)
committerGitHub <noreply@github.com>2020-11-04 15:37:07 (GMT)
commit18ce7f1d0a3d65f34f25c5964da588743a1bfe3c (patch)
tree3ac5d34560a9af7ad1ab27abfc54174ca7bda82a /Parser/asdl_c.py
parent988f1ec8d2643a0d00851903abcdae90d57ac0e6 (diff)
downloadcpython-18ce7f1d0a3d65f34f25c5964da588743a1bfe3c.zip
cpython-18ce7f1d0a3d65f34f25c5964da588743a1bfe3c.tar.gz
cpython-18ce7f1d0a3d65f34f25c5964da588743a1bfe3c.tar.bz2
bpo-1635741: _ast uses PyModule_AddObjectRef() (GH-23146)
Replace PyModule_AddObject() with PyModule_AddObjectRef() in the _ast module (Python-ast.c).
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-xParser/asdl_c.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 9fec7ae..34bd701 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -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):