diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-06-01 17:08:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-01 17:08:04 (GMT) |
commit | cd74e66a8c420be675fd2fbf3fe708ac02ee9f21 (patch) | |
tree | 12f985512507967c339019c4c21b4a613cd6c61b /Doc | |
parent | 059b9ea5ac98f432e41b05d1fa5aab4ffa22df4d (diff) | |
download | cpython-cd74e66a8c420be675fd2fbf3fe708ac02ee9f21.zip cpython-cd74e66a8c420be675fd2fbf3fe708ac02ee9f21.tar.gz cpython-cd74e66a8c420be675fd2fbf3fe708ac02ee9f21.tar.bz2 |
bpo-37122: Make co->co_argcount represent the total number of positonal arguments in the code object (GH-13726)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/code.rst | 2 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 36 | ||||
-rw-r--r-- | Doc/whatsnew/3.8.rst | 6 |
3 files changed, 25 insertions, 19 deletions
diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 7aa91ee..92baa4c 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -42,6 +42,8 @@ bound into a function. .. versionchanged:: 3.8 An extra parameter is required (*posonlyargcount*) to support :PEP:`570`. + The first parameter (*argcount*) now represents the total number of positional arguments, + including positional-only. .. audit-event:: code.__new__ "code filename name argcount kwonlyargcount nlocals stacksize flags" diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index c566dfd..44017d8 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -907,24 +907,26 @@ Internal types single: co_freevars (code object attribute) Special read-only attributes: :attr:`co_name` gives the function name; - :attr:`co_argcount` is the number of positional arguments (including arguments - with default values); :attr:`co_posonlyargcount` is the number of - positional-only arguments (including arguments with default values); - :attr:`co_kwonlyargcount` is the number of keyword-only arguments (including - arguments with default values); :attr:`co_nlocals` is the number of local - variables used by the function (including arguments); :attr:`co_varnames` is a - tuple containing the names of the local variables (starting with the argument - names); :attr:`co_cellvars` is a tuple containing the names of local variables + :attr:`co_argcount` is the total number of positional arguments + (including positional-only arguments and arguments with default values); + :attr:`co_posonlyargcount` is the number of positional-only arguments + (including arguments with default values); :attr:`co_kwonlyargcount` is + the number of keyword-only arguments (including arguments with default + values); :attr:`co_nlocals` is the number of local variables used by the + function (including arguments); :attr:`co_varnames` is a tuple containing + the names of the local variables (starting with the argument names); + :attr:`co_cellvars` is a tuple containing the names of local variables that are referenced by nested functions; :attr:`co_freevars` is a tuple - containing the names of free variables; :attr:`co_code` is a string representing - the sequence of bytecode instructions; :attr:`co_consts` is a tuple containing - the literals used by the bytecode; :attr:`co_names` is a tuple containing the - names used by the bytecode; :attr:`co_filename` is the filename from which the - code was compiled; :attr:`co_firstlineno` is the first line number of the - function; :attr:`co_lnotab` is a string encoding the mapping from bytecode - offsets to line numbers (for details see the source code of the interpreter); - :attr:`co_stacksize` is the required stack size (including local variables); - :attr:`co_flags` is an integer encoding a number of flags for the interpreter. + containing the names of free variables; :attr:`co_code` is a string + representing the sequence of bytecode instructions; :attr:`co_consts` is + a tuple containing the literals used by the bytecode; :attr:`co_names` is + a tuple containing the names used by the bytecode; :attr:`co_filename` is + the filename from which the code was compiled; :attr:`co_firstlineno` is + the first line number of the function; :attr:`co_lnotab` is a string + encoding the mapping from bytecode offsets to line numbers (for details + see the source code of the interpreter); :attr:`co_stacksize` is the + required stack size (including local variables); :attr:`co_flags` is an + integer encoding a number of flags for the interpreter. .. index:: object: generator diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 2d52911..4c5a9bb 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -1177,8 +1177,10 @@ Changes in the Python API * :class:`types.CodeType` has a new parameter in the second position of the constructor (*posonlyargcount*) to support positional-only arguments defined - in :pep:`570`. A new ``replace()`` method of :class:`types.CodeType` can be - used to make the code future-proof. + in :pep:`570`. The first argument (*argcount*) now represents the total + number of positional arguments (including positional-only arguments). A new + ``replace()`` method of :class:`types.CodeType` can be used to make the code + future-proof. Changes in the C API |