Commit 8392f365 authored by Jeremy Hylton's avatar Jeremy Hylton

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.
parent c9319b37
...@@ -730,8 +730,8 @@ number of local variables used by the function (including arguments); ...@@ -730,8 +730,8 @@ number of local variables used by the function (including arguments);
variables (starting with the argument names); \member{co_cellvars} is variables (starting with the argument names); \member{co_cellvars} is
a tuple containing the names of local variables that are referenced by a tuple containing the names of local variables that are referenced by
nested functions; \member{co_freevars} is a tuple containing the names nested functions; \member{co_freevars} is a tuple containing the names
of local variables that are neither local nor global; \member{co_code} of free variables; \member{co_code} is a string representing the
is a string representing the sequence of bytecode instructions; sequence of bytecode instructions;
\member{co_consts} is a tuple containing the literals used by the \member{co_consts} is a tuple containing the literals used by the
bytecode; \member{co_names} is a tuple containing the names used by bytecode; \member{co_names} is a tuple containing the names used by
the bytecode; \member{co_filename} is the filename from which the code the bytecode; \member{co_filename} is the filename from which the code
...@@ -742,10 +742,6 @@ the interpreter); \member{co_stacksize} is the required stack size ...@@ -742,10 +742,6 @@ the interpreter); \member{co_stacksize} is the required stack size
(including local variables); \member{co_flags} is an integer encoding (including local variables); \member{co_flags} is an integer encoding
a number of flags for the interpreter. a number of flags for the interpreter.
The \member{co_cellvars} and \member{co_freevars} are present in
Python 2.1 when nested scopes are not enabled, but the code itself
does not use or create cells.
\withsubitem{(code object attribute)}{ \withsubitem{(code object attribute)}{
\ttindex{co_argcount} \ttindex{co_argcount}
\ttindex{co_code} \ttindex{co_code}
...@@ -766,10 +762,19 @@ The following flag bits are defined for \member{co_flags}: bit ...@@ -766,10 +762,19 @@ The following flag bits are defined for \member{co_flags}: bit
\code{0x04} is set if the function uses the \samp{*arguments} syntax \code{0x04} is set if the function uses the \samp{*arguments} syntax
to accept an arbitrary number of positional arguments; bit to accept an arbitrary number of positional arguments; bit
\code{0x08} is set if the function uses the \samp{**keywords} syntax \code{0x08} is set if the function uses the \samp{**keywords} syntax
to accept arbitrary keyword arguments; other bits are used internally to accept arbitrary keyword arguments; bit \code{0x20} is set if the
or reserved for future use; bit \code{0x10} is set if the function was function is a \obindex{generator}.
compiled with nested scopes enabled. If\index{documentation string} a
code object represents a function, the first item in Future feature declarations (\samp{from __future__ import division})
also use bits in \member{co_flags} to indicate whether a code object
was compiled with a particular feature enabled: bit \code{0x2000} is
set if the function was compiled with future division enabled; bits
\code{0x10} and \code{0x1000} were used in earlier versions of Python.
Other bits in \member{co_flags} are reserved for internal use.
If\index{documentation string} a code object represents a function,
the first item in
\member{co_consts} is the documentation string of the function, or \member{co_consts} is the documentation string of the function, or
\code{None} if undefined. \code{None} if undefined.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment