Skip to content

"run -i" no longer works after %reset in terminal #693

@rabbitmcrabbit

Description

@rabbitmcrabbit

this appears to be a result of __name__ being lost:

/usr/local/lib/python2.6/dist-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s, next_input)
   1892                 self._magic_locals = sys._getframe(1).f_locals
   1893             with self.builtin_trap:
-> 1894                 result = fn(magic_args)
   1895             # Ensure we're not keeping object references around:

   1896             self._magic_locals = {}

/usr/local/lib/python2.6/dist-packages/IPython/core/magic.pyc in magic_run(self, parameter_s, runner, file_finder)
   1587             # Run in user's interactive namespace

   1588             prog_ns = self.shell.user_ns
-> 1589             __name__save = self.shell.user_ns['__name__']
   1590             prog_ns['__name__'] = '__main__'
   1591             main_mod = self.shell.new_main_mod(prog_ns)

KeyError: '__name__'


In [1]: dir()
Out[1]: 
['In',
 'Out',
 '_',
 '__',
 '___',
 '__builtin__',
 '__builtins__',
 '__name__',
 '_dh',
 '_i',
 '_i1',
 '_ih',
 '_ii',
 '_iii',
 '_oh',
 '_sh',
 'exit',
 'get_ipython',
 'help',
 'quit']

In [2]: __name__
Out[2]: '__main__'

In [3]: %reset
Once deleted, variables cannot be recovered. Proceed (y/[n])?  y

In [4]: dir()
Out[4]: 
['In',
 'Out',
 '__builtin__',
 '__builtins__',
 '_dh',
 '_i',
 '_i4',
 '_ih',
 '_ii',
 '_iii',
 '_oh',
 '_sh',
 'exit',
 'get_ipython',
 'help',
 'quit']

In [5]: __name__
Out[5]: '__builtin__'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions