[issue36697] inspect.getclosurevars returns wrong globals dict
Daniel Debrunner
report at bugs.python.org
Mon Oct 7 15:07:31 EDT 2019
Daniel Debrunner <djd at debrunners.com> added the comment:
Another case:
model="Hello"
class M(object):
def __init__(self):
pass
def __call__(self):
print(self.model)
cvs = inspect.getclosurevars(M.__call__)
ClosureVars(nonlocals={}, globals={'model': 'Hello'}, builtins={'print': <built-in function print>}, unbound=set())
Of course self.model does not refer to the global model
M()()
AttributeError: 'M' object has no attribute 'model'
----------
nosy: +Daniel Debrunner
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36697>
_______________________________________
More information about the Python-bugs-list
mailing list