It appears that pdb does not inherit local globals(). Thus we actually see the globals of python-console not the ones the user has defined.
IVLE console
==========
>>> def x():
... print 1
...
>>> import pdb
>>> pdb.run('x()')
> <string>(1)<module>()
(Pdb) +++ s
NameError: "name 'x' is not defined"
> <string>(1)<module>()
(Pdb)
>>> pdb.run('print globals()')
> <string>(1)<module>()->None
(Pdb) +++ c
{'ivle': <module 'ivle' from '/usr/lib/python2.5/site-packages/ivle/__init__.pyc'>, 'cStringIO': <module 'cStringIO' from '/usr/lib/python2.5/lib-dynload/cStringIO.so'>, 'format_exc_start': <function format_exc_start at 0x8672a8>, 'sig_handler': <function sig_handler at 0x8671b8>, 'terminate': None, 'initializer': <function initializer at 0x8aea28>, 'StdoutToWeb': <class '__main__.StdoutToWeb'>, 'StdinFromWeb': <class '__main__.StdinFromWeb'>, 'flatten': <function flatten at 0x867320>, 'port': 4537, 'PythonRunner': <class '__main__.PythonRunner'>, 'dispatch_msg': <function dispatch_msg at 0x867230>, 'interpThread': <PythonRunner(Thread-1, started daemon)>, 'Interrupt': <class '__main__.Interrupt'>, '__doc__': None, 'cPickle': <module 'cPickle' from '/usr/lib/python2.5/lib-dynload/cPickle.so'>, 'Thread': <class 'threading.Thread'>, '__builtins__': <module '__builtin__' (built-in)>, '__file__': '/usr/share/ivle/services/python-console', 'ExpiryTimer': <class '__main__.ExpiryTimer'>, 'lineQ': <Queue.Queue instance at 0x85d7e8>, 'expiry': <__main__.ExpiryTimer object at 0x866550>, 'Queue': <module 'Queue' from '/usr/lib/python2.5/Queue.pyc'>, '__exception__': (<type 'exceptions.NameError'>, "name 'main' is not defined"), 'codeop': <module 'codeop' from '/usr/lib/python2.5/codeop.pyc'>, '__name__': '__main__', 'md5': <module 'md5' from '/usr/lib/python2.5/md5.pyc'>, 'sys': <module 'sys' (built-in)>, 'magic': '1d6efdeca7a35de4f9770bd3b47e7f21', 'socket': <module 'socket' from '/usr/lib/python2.5/socket.pyc'>, 'WebIO': <class '__main__.WebIO'>, 'signal': <module 'signal' (built-in)>, 'traceback': <module 'traceback' from '/usr/lib/python2.5/traceback.pyc'>, 'cmdQ': <Queue.Queue instance at 0x85d8c0>, '__return__': None, 'PICKLEVERSION': 0}
cPython console
=============
>>> def x():
... print 1
...
>>> import pdb
>>> pdb.run('x()')
> <string>(1)<module>()
(Pdb) s
--Call--
> <stdin>(1)x()
(Pdb) s
> <stdin>(2)x()
(Pdb) s
1
--Return--
> <stdin>(2)x()->None
A workaround is to use `pdb.run(stmt, globals=globals())`