Thomas Kluyver
Thomas Kluyver
(Oh, and in case it's not obvious, the `sys._getframe()` thing needs to be directly in a code cell, not wrapped in a function. You could walk the stack from inside...
I see that [locust uses gevent](https://github.com/locustio/locust/blob/master/locust/core.py), and here's a [similar but different issue filed on gevent](https://github.com/gevent/gevent/issues/446). So my guess would be that this is gevent casually [breaking the standard library](https://github.com/gevent/gevent/blob/8412311e9b29c3317941a5306176faf535f6f4b1/src/gevent/monkey.py#L494).
Is this likely to be the same issue as #62?
Assigned this to myself to look at.
Unfortunately, I think this is a limitation of Python itself. It appears code compiled dynamically cannot define a closure, which is essentially what we're doing here with a generator expression....
I think it may be possible to make this work using `collections.ChainMap` from Python 3.3 so that IPython sees both local and global variables where it is embedded as globals....
Is this sufficient to avoid the problem you encountered? It looks like there are other `exists()` checks in `get_template_names()` which could also run into permission errors. (It also seems weird...
Fair enough. I'm just going to close & reopen this to re-run the tests with the fix from #2168. It certainly can be surprising, but I think I prefer it...