This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: symtable.symtable can return the wrong "top" SymbolTable
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: Steven.Winfield, benjamin.peterson, brett.cannon, georg.brandl, ncoghlan, python-dev
Priority: normal Keywords:

Created on 2013-10-25 17:49 by Steven.Winfield, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
symtable_weirdness.py Steven.Winfield, 2013-10-25 17:49 Script to reproduce the problem. Python 2 and 3 comapatible.
Messages (2)
msg201265 - (view) Author: Steven Winfield (Steven.Winfield) * Date: 2013-10-25 17:49
The attached script creates calls symtable.symtable many times on a code snippet that contains a single class with a method called "top", and some other important (to trigger the behaviour) properties:
  * a class variable
  * at least three other methods

The symtable module is reloaded each time, which seems to exacerbate the problem, but it not necessary.

The return value of symtable.symtable is sometimes a SymbolTable object, as expected, and sometimes a symtable.Function object.

Here is some example output from the script:

c:\Python27>python.exe C:\Temp\symtable_weirdness.py
Counter({'SymbolTable': 59, 'Function': 41})

c:\Python33>python.exe C:\Temp\symtable_weirdness.py
Counter({'SymbolTable': 89, 'Function': 11})

The values are consistent between runs, but can be changed by altering PYTHONHASHSEED between runs.
msg201378 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-26 17:22
New changeset bc259b221cb8 by Benjamin Peterson in branch '3.3':
just return toplevel symbol table rather than all blocks (closes #19393)
http://hg.python.org/cpython/rev/bc259b221cb8

New changeset f1b7b5979e96 by Benjamin Peterson in branch '2.7':
just return toplevel symbol table rather than all blocks (closes #19393)
http://hg.python.org/cpython/rev/f1b7b5979e96

New changeset f5c729dbe9fb by Benjamin Peterson in branch 'default':
merge 3.3 (#19393)
http://hg.python.org/cpython/rev/f5c729dbe9fb
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63592
2013-10-26 17:22:43python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg201378

resolution: fixed
stage: resolved
2013-10-26 16:57:12benjamin.petersonsetassignee: benjamin.peterson
2013-10-26 16:50:52pitrousetnosy: + brett.cannon, georg.brandl, ncoghlan, benjamin.peterson
2013-10-25 17:49:55Steven.Winfieldcreate