Kozea / wdb

An improbable web debugger through WebSockets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NameError() in simple script

garfieldnate opened this issue · comments

I have this very simple script that runs perfectly fine without wdb:

def foo():
    bar()

def bar():
    pass

if __name__ == '__main__':
    foo()

However, when I run it with -m wdb I get a strange NameError:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.6/site-packages/wdb/__main__.py", line 63, in <module>
    main()
  File "/usr/local/lib/python3.6/site-packages/wdb/__main__.py", line 49, in main
    execute(code, globals(), locals())
  File "/usr/local/lib/python3.6/site-packages/wdb/_compat.py", line 43, in execute
    exec(cmd, globals_, locals_)
  File "/Users/me/working_directory/wdb_test.py", line 8, in <module>
    foo()
  File "/Users/me/working_directory/wdb_test.py", line 2, in foo
    bar()
NameError: name 'bar' is not defined

The wdb window still opens in the browser, but the first command to step (.u, .n or .s) then immediately exits the debugger and the entire program.

I am using Mac OS 10.12.6 (Sierra) and Python versions 2.7.13 and 3.6.0 (without -m wdb the script runs fine on both).

Thanks!