diff options
author | 2020-11-04 16:37:07 +0100 | |
---|---|---|
committer | 2020-11-04 16:37:07 +0100 | |
commit | 18ce7f1d0a3d65f34f25c5964da588743a1bfe3c (patch) | |
tree | 3ac5d34560a9af7ad1ab27abfc54174ca7bda82a /Parser | |
parent | bpo-1635741: _contextvars uses PyModule_AddType() (GH-23147) (diff) | |
download | cpython-18ce7f1d0a3d65f34f25c5964da588743a1bfe3c.tar.gz cpython-18ce7f1d0a3d65f34f25c5964da588743a1bfe3c.tar.bz2 cpython-18ce7f1d0a3d65f34f25c5964da588743a1bfe3c.zip |
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')
-rwxr-xr-x | Parser/asdl_c.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 9fec7ae017..34bd7010cf 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): |