Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
take advises
  • Loading branch information
xuantengh committed Oct 30, 2024
commit 6ebadd6e604337d463d6b5d383300809ce03303a
2 changes: 1 addition & 1 deletion Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ Other bits in :attr:`~codeobject.co_flags` are reserved for internal use.

If a code object represents a function and has a docstring,
the first item in :attr:`~codeobject.co_consts` is
the documentation string of the function.
the docstring of the function.

Methods on code objects
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ struct PyCodeObject _PyCode_DEF(1);

#define CO_NO_MONITORING_EVENTS 0x2000000

/* Whether the first element in co_consts is doc string */
/* Whether the code object has a docstring,
If so, it will be the first item in co_consts
*/
#define CO_HAS_DOCSTRING 0x4000000

/* This should be defined if a future statement modifies the syntax.
Expand Down
2 changes: 1 addition & 1 deletion Python/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ codegen_function_body(compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags
return ERROR;
}
Py_ssize_t idx = _PyCompile_AddConst(c, docstring);
Py_XDECREF(docstring);
Py_DECREF(docstring);
RETURN_IF_ERROR_IN_SCOPE(c, idx < 0 ? ERROR : SUCCESS);
Comment thread
xuantengh marked this conversation as resolved.
}

Expand Down