This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Autocompletion crashes Python if the __builtins__ module cannot be found.
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.2
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 2022-04-11 14:57 by admin. 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__


    builtins = __builtins__
    del __builtins__

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

    *** Internal Error:

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

    Traceback (most recent call last):
      File "C:\Python32\lib\idlelib\", line 188, in localcall
        ret = method(*args, **kwargs)
      File "C:\Python32\lib\idlelib\", line 327, in get_the_completion_list
        return self.autocomplete.fetch_completions(what, mode)
      File "C:\Python32\lib\idlelib\", line 189, in fetch_completions
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.
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59588
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