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

Skip to content

Commit 8392f36

Browse files
committed
Update documentation of code objects.
Split the description of co_flags into two paragraphs. The first describes the flags that are used for non-future purposes, where CO_GENERATOR was added. The second describes __future__'s use of co_flags and mentions the only one currently meaningful, CO_FUTURE_DIVISION.
1 parent c9319b3 commit 8392f36

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

Doc/ref/ref3.tex

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ \section{The standard type hierarchy\label{types}}
730730
variables (starting with the argument names); \member{co_cellvars} is
731731
a tuple containing the names of local variables that are referenced by
732732
nested functions; \member{co_freevars} is a tuple containing the names
733-
of local variables that are neither local nor global; \member{co_code}
734-
is a string representing the sequence of bytecode instructions;
733+
of free variables; \member{co_code} is a string representing the
734+
sequence of bytecode instructions;
735735
\member{co_consts} is a tuple containing the literals used by the
736736
bytecode; \member{co_names} is a tuple containing the names used by
737737
the bytecode; \member{co_filename} is the filename from which the code
@@ -742,10 +742,6 @@ \section{The standard type hierarchy\label{types}}
742742
(including local variables); \member{co_flags} is an integer encoding
743743
a number of flags for the interpreter.
744744

745-
The \member{co_cellvars} and \member{co_freevars} are present in
746-
Python 2.1 when nested scopes are not enabled, but the code itself
747-
does not use or create cells.
748-
749745
\withsubitem{(code object attribute)}{
750746
\ttindex{co_argcount}
751747
\ttindex{co_code}
@@ -766,10 +762,19 @@ \section{The standard type hierarchy\label{types}}
766762
\code{0x04} is set if the function uses the \samp{*arguments} syntax
767763
to accept an arbitrary number of positional arguments; bit
768764
\code{0x08} is set if the function uses the \samp{**keywords} syntax
769-
to accept arbitrary keyword arguments; other bits are used internally
770-
or reserved for future use; bit \code{0x10} is set if the function was
771-
compiled with nested scopes enabled. If\index{documentation string} a
772-
code object represents a function, the first item in
765+
to accept arbitrary keyword arguments; bit \code{0x20} is set if the
766+
function is a \obindex{generator}.
767+
768+
Future feature declarations (\samp{from __future__ import division})
769+
also use bits in \member{co_flags} to indicate whether a code object
770+
was compiled with a particular feature enabled: bit \code{0x2000} is
771+
set if the function was compiled with future division enabled; bits
772+
\code{0x10} and \code{0x1000} were used in earlier versions of Python.
773+
774+
Other bits in \member{co_flags} are reserved for internal use.
775+
776+
If\index{documentation string} a code object represents a function,
777+
the first item in
773778
\member{co_consts} is the documentation string of the function, or
774779
\code{None} if undefined.
775780

0 commit comments

Comments
 (0)