[New-bugs-announce] [issue40926] command line interface of symtable module is broken

Batuhan Taskaya report at bugs.python.org
Tue Jun 9 06:20:39 EDT 2020


New submission from Batuhan Taskaya <isidentical at gmail.com>:

(.venv) (Python 3.10.0a0) [  1:11ÖS ]  [ isidentical at x200:~ ]
 $ cat t.py
import x
a = 1
print(x)

(.venv) (Python 3.10.0a0) [  1:11ÖS ]  [ isidentical at x200:~ ]
 $ python -m symtable t.py
<symbol '_symtable'> True False
<symbol 'USE'> True False
<symbol 'DEF_GLOBAL'> True False
<symbol 'DEF_NONLOCAL'> True False
<symbol 'DEF_LOCAL'> True False
...

It can clearly seen that the initial argument [t.py] is completely ignored, and this script prints out the symtable.py itself. This is because the script uses argv[0] (itself) instead of argv[1] (the first argument). I also find this output quite poor since we don't know what these boolean values are;

<symbol 'DEF_LOCAL'> True False

The fix I had in my mind is printing all properties instead of 2 boolean values

 $ ./cpython/cpython/python -m symtable t.py
<symbol 'x'> ==> {'local', 'imported', 'referenced'}
<symbol 'a'> ==> {'local', 'assigned'}
<symbol 'print'> ==> {'referenced', 'global'}

----------
components: Library (Lib)
messages: 371088
nosy: BTaskaya
priority: normal
severity: normal
stage: needs patch
status: open
title: command line interface of symtable module is broken
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40926>
_______________________________________


More information about the New-bugs-announce mailing list