Skip to content

Commit 49d3254

Browse files
committed
update __doc__ for function object
1 parent 13602e2 commit 49d3254

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

Objects/funcobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname
162162
PyObject *consts = code_obj->co_consts;
163163
assert(PyTuple_Check(consts));
164164
PyObject *doc;
165-
if (PyTuple_Size(consts) >= 1) {
165+
if (PyTuple_Size(consts) >= 1 && code_obj->co_flags & CO_HAS_DOCSTRING) {
166166
doc = PyTuple_GetItem(consts, 0);
167167
if (!PyUnicode_Check(doc)) {
168168
doc = Py_None;

Python/codegen.c

-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ _PyCodegen_Body(compiler *c, location loc, asdl_stmt_seq *stmts, bool is_interac
772772
assert(st->kind == Expr_kind);
773773
location loc = LOC(st->v.Expr.value);
774774
ADDOP_LOAD_CONST(c, loc, cleandoc);
775-
776775
Py_DECREF(cleandoc);
777776
RETURN_IF_ERROR(codegen_nameop(c, NO_LOCATION, &_Py_ID(__doc__), Store));
778777
}

0 commit comments

Comments
 (0)