classification
Title: Autocompletion crashes Python if the __builtins__ module cannot be found.
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: IDLE Shell: delattr(__builtins__,"getattr") causes shell to stop working
View: 15113
Assigned To: Nosy List: Tyler.Crompton, r.david.murray
Priority: normal Keywords:

Created on 2012-07-18 05:08 by Tyler.Crompton, last changed 2012-07-18 11:13 by r.david.murray. This issue is now closed.

Messages (2)
msg165741 - (view) Author: Tyler Crompton (Tyler.Crompton) Date: 2012-07-18 05:08
Doing one of the following crashes Python.

    del __builtins__
    a{Tab}

or

    builtins = __builtins__
    del __builtins__
    a{Tab}

If you do a print screen, immediately, you will see the following error:

    *** Internal Error: rpc.py:SocketIO.localcall()

     Object: exec
     Method: <bound method Executive.get_the_completion_list of <idlelib.run.Executive object at 0x0000000002DC2710>>
     Args: ('', 1)

    Traceback (most recent call last):
      File "C:\Python32\lib\idlelib\rpc.py", line 188, in localcall
        ret = method(*args, **kwargs)
      File "C:\Python32\lib\idlelib\run.py", line 327, in get_the_completion_list
        return self.autocomplete.fetch_completions(what, mode)
      File "C:\Python32\lib\idlelib\AutoComplete.py", line 189, in fetch_completions
        namespace.update(__main__.__builtins__.__dict__)
AttributeError: 'module' object has no attribute '__builtins__'

Additionally, when __builtins__ is deleted (in IDLE), __builtins__ becomes a dictionary. If one were to then do __builtins__.clear(), the interpreter stops all interpreting. IDLE moreorless becomes a text editor with syntax highlighting. If you try to use autocomplete, Python hangs before crashing.

I realize that doing such is pointless, but it behaves differently than interactive console interpreters. Interactive console interpreters don't convert __builtins__ to a dictionary upon its deletion. I feel that this error can be handled to prevent crashing.
msg165755 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-07-18 11:13
This is the same as issue 15113.  If you delete __builtins__, don't expect Python to work.
History
Date User Action Args
2012-07-18 11:13:00r.david.murraysetstatus: open -> closed

superseder: IDLE Shell: delattr(__builtins__,"getattr") causes shell to stop working
nosy: + r.david.murray

messages: + msg165755
type: crash -> behavior
resolution: duplicate
stage: resolved
2012-07-18 05:08:42Tyler.Cromptoncreate