aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/codegen.c
diff options
context:
space:
mode:
authorXuanteng Huang <44627253+xuantengh@users.noreply.github.com>2024-10-30 17:01:09 +0800
committerGitHub <noreply@github.com>2024-10-30 09:01:09 +0000
commit35df4eb959b3923c08aaaeff728c5ed1706f31cf (patch)
tree0066d2a27b47aaa3fc3dde9debcfd9b553579565 /Python/codegen.c
parent2ab377a47c8290f8bf52c8ffb5d7fc4c45452611 (diff)
downloadcpython-35df4eb959b3923c08aaaeff728c5ed1706f31cf.tar.gz
cpython-35df4eb959b3923c08aaaeff728c5ed1706f31cf.zip
gh-126072: do not add `None` to `co_consts` if there is no docstring (GH-126101)
Diffstat (limited to 'Python/codegen.c')
-rw-r--r--Python/codegen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/codegen.c b/Python/codegen.c
index 976c94234d6..d79aee4859e 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -1243,10 +1243,10 @@ codegen_function_body(compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags
_PyCompile_ExitScope(c);
return ERROR;
}
+ Py_ssize_t idx = _PyCompile_AddConst(c, docstring);
+ Py_DECREF(docstring);
+ RETURN_IF_ERROR_IN_SCOPE(c, idx < 0 ? ERROR : SUCCESS);
}
- Py_ssize_t idx = _PyCompile_AddConst(c, docstring ? docstring : Py_None);
- Py_XDECREF(docstring);
- RETURN_IF_ERROR_IN_SCOPE(c, idx < 0 ? ERROR : SUCCESS);
NEW_JUMP_TARGET_LABEL(c, start);
USE_LABEL(c, start);