Skip to content

doc: update co_flags reference #132300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1526,18 +1526,17 @@ positional arguments; bit ``0x08`` is set if the function uses the
if the function is a generator. See :ref:`inspect-module-co-flags` for details
on the semantics of each flags that might be present.

Future feature declarations (``from __future__ import division``) also use bits
Future feature declarations (e.g. ``from __future__ import division``) also use bits
in :attr:`~codeobject.co_flags` to indicate whether a code object was compiled with a
particular feature enabled: bit ``0x2000`` is set if the function was compiled
with future division enabled; bits ``0x10`` and ``0x1000`` were used in earlier
versions of Python.
particular feature enabled. See :attr:`~__future__._Feature.compiler_flag`.

Other bits in :attr:`~codeobject.co_flags` are reserved for internal use.

.. index:: single: documentation string

If a code object represents a function and has a docstring,
the first item in :attr:`~codeobject.co_consts` is
the :data:`~inspect.CO_HAS_DOCSTRING` bit is set in :attr:`~codeobject.co_flags`
and the first item in :attr:`~codeobject.co_consts` is
the docstring of the function.

Methods on code objects
Expand Down
Loading