[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-12-19 Thread STINNER Victor

STINNER Victor  added the comment:

Thanks Paul Sokolovsky for the bug report and thanks Batuhan Taşkaya for the 
fix ;-)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-12-19 Thread miss-islington

miss-islington  added the comment:


New changeset eba61f33d60cc63e35d5f5fcada837a66c89774a by Miss Islington (bot) 
(Batuhan Taşkaya) in branch '3.8':
[3.8] bpo-38316: Fix co_stacksize documentation (GH-16983) (GH-17661)
https://github.com/python/cpython/commit/eba61f33d60cc63e35d5f5fcada837a66c89774a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-12-19 Thread miss-islington

miss-islington  added the comment:


New changeset 917419f58b2869d71691c5ba54a9e02e5dcf73b2 by Miss Islington (bot) 
(Batuhan Taşkaya) in branch '3.7':
[3.7] bpo-38316: Fix co_stacksize documentation (GH-16983). (GH-17660)
https://github.com/python/cpython/commit/917419f58b2869d71691c5ba54a9e02e5dcf73b2


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-12-19 Thread Batuhan


Change by Batuhan :


--
pull_requests: +17128
pull_request: https://github.com/python/cpython/pull/17660

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-12-19 Thread Batuhan


Change by Batuhan :


--
pull_requests: +17129
pull_request: https://github.com/python/cpython/pull/17661

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-12-15 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset d587272fe3b0fcad2f23a490e76f9f82ca7d64ef by Victor Stinner 
(Batuhan Taşkaya) in branch 'master':
 bpo-38316: Fix co_stacksize documentation (GH-16983)
https://github.com/python/cpython/commit/d587272fe3b0fcad2f23a490e76f9f82ca7d64ef


--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-10-29 Thread Batuhan


Change by Batuhan :


--
keywords: +patch
pull_requests: +16509
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/16983

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-10-04 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions:  -Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-09-29 Thread Ammar Askar


Ammar Askar  added the comment:

Yeah, that parenthesized bit seems a bit weird: co_stacksize really has nothing 
to do with the number of variables, it's just that certain opcodes 
(https://docs.python.org/3/library/dis.html#python-bytecode-instructions) push 
and pop off the stack, co_stacksize is just the largest the stack will ever 
grow to from these operations.

For example:

  >>> def f():
  ...   a = 1
  ...   b = 2
  ...   c = 3
  ...   g(a, b, c)
  ...
  >>> f.__code__.co_stacksize
  4

and

  >>> def g():
  ...   g(1, 2, 3)
  ...
  >>> g.__code__.co_stacksize
  4

have the exact same stack size despite differences in variables because the 
call to `g` has to push all 3 operands (and g itself) onto the stack.

--
nosy: +ammar2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-09-29 Thread Paul Sokolovsky


New submission from Paul Sokolovsky :

CPython's Data Model -> Internal types -> Code objects, direct link as of 
version 3.7 is: 
https://docs.python.org/3.7/reference/datamodel.html?highlight=co_stacksize#index-55
 , states following:

* "co_nlocals is the number of local variables used by the function (including 
arguments);"
* "co_stacksize is the required stack size (including local variables);"

However, practical checking shows that co_stacksize is the required stack size 
WITHOUT local variables. One could argue about the meaning of "local variables" 
in the description of co_stacksize above, saying that what is meant is 
temporary stack variables of something. That's why I quoted above co_nlocals 
description too, it clearly shows that local variebles are local function 
variables (include functions args), and nothing else.

Code to reproduce:

==
def func():
a = 1
b = 2
c = 3

print("co_stacksize", func.__code__.co_stacksize)
print("co_nlocals", func.__code__.co_nlocals)
==

Result of running:
==
$ python3.7 script_under_test.py 
co_stacksize 1
co_nlocals 3
==

Clearly, co_stacksize doesn't include the size of local vars, or it would have 
been larger than co_nlocals in printout.

--
assignee: docs@python
components: Documentation
messages: 353508
nosy: docs@python, pfalcon
priority: normal
severity: normal
status: open
title: docs: Code object's "co_stacksize" field is described with mistake
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com