[issue36697] inspect.getclosurevars returns wrong globals dict

2019-10-07 Thread Daniel Debrunner
Daniel Debrunner 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': },

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-23 Thread Noitul
Noitul added the comment: Look at this https://github.com/python/cpython/blob/3.6/Lib/inspect.py#L1412 We are taking names from func.__code__.co_names, which also contains names of object's attributes we visited. As a result, we may get more names unexpectedly in 'globals', 'builtins', and

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-23 Thread Eric V. Smith
Eric V. Smith added the comment: That is interesting. See these examples. I'm starting a new interpreter each time: >>> import inspect >>> def abc(): pass ... >>> inspect.getclosurevars(abc) ClosureVars(nonlocals={}, globals={}, builtins={}, unbound=set()) >>> >>> import inspect >>> def

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-23 Thread Noitul
Noitul 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

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-23 Thread Eric V. Smith
Eric V. Smith added the comment: I think this is correct. The documentation says globals is "the function’s module globals". I suggest closing this as not a bug. https://docs.python.org/3/library/inspect.html#inspect.getclosurevars -- nosy: +eric.smith status: open -> pending type:

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-22 Thread Nitish
Change by Nitish : -- nosy: +nitishch ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-22 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +yselivanov ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36697] inspect.getclosurevars returns wrong globals dict

2019-04-22 Thread Noitul
New submission from Noitul : >>> import inspect >>> a = 0 >>> b = 1 >>> def abc(): >>> return a.b >>>