[issue36697] inspect.getclosurevars returns wrong globals dict

Noitul report at bugs.python.org
Tue Apr 23 05:45:03 EDT 2019


Noitul <qazazsw at gmail.com> added the comment:

Sorry for the misleading snippet above.

And how about this one:

>>> import inspect                      
>>> a = 0                               
>>> b = 1
>>> c = 2                               
>>> def abc():                          
>>>     return a.b                                                      
>>> print(inspect.getclosurevars(abc))  

ClosureVars(nonlocals={}, globals={'a': 0, 'b': 1}, builtins={}, unbound=set())

If this is not a bug, the "globals" is the "function's module globals", but why 'c' not in the "globals"?

----------
status: pending -> open

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


More information about the Python-bugs-list mailing list