NameError when referencing defined globals in the debugger. #913
Running werkzeug .10.4 wrapped around Django via Django-Extensions to use the Don't Panic! debugger in dev environments. Version of Python is 2.7.8.
I'm running into an issue where I can't access variables defined in the session from lambdas or functions defined in the debugger. Example:
import os map(lambda x: os.path.basename(x.name), bucket.list())
import os def get_key_basename(key): return os.path.basename(key.name) map(get_key_basename, bucket.list())
Happens with pretty much any variable in the debugger's scope.
I see the the code being passed to Don't Panic through the dev server (
We are running with reloading, but no reloading happens between starting the debugger and the NameError occurring.
If I've simply missed something, feel free to close this. Otherwise, I'm happy to provide my information as needed.
Yeah, here's the simplest app that can reproduce.
from werkzeug.debug import DebuggedApplication from werkzeug.serving import run_simple def app(environ, start_response): raise Exception if __name__ == '__main__': run_simple('localhost', 8000, DebuggedApplication(app, evalex=True))
Poking about some, it seems like debugger variables including imports get added to
# inside running debugged application import os (lambda: os)() # NameError 'os' in globals() # False 'os' in locals() # True globals()['os'] = os (lambda: os)() # <module 'os' ...> 'os' in globals() # True
Edit: This manifests in 2.7 and 3.5. I initially encountered it in Py 2.7, Werkzeug 0.10.4, but it manifests in 0.11.9 as well.