[New-bugs-announce] [issue3938] Clearing globals; interpreter -- IDLE difference

Terry J. Reedy report at bugs.python.org
Tue Sep 23 00:45:02 CEST 2008

New submission from Terry J. Reedy <tjreedy at udel.edu>:

>>> globals()
{'__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__',
'__doc__': None, '__package__': None}
>>> globals().clear()
>>> globals()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'globals' is not defined

Though not what one would usually want, .clear() clears all.  One now
has a bare interpreter with import disabled ('__import__' not found).

>>> globals().clear()
>>> __name__
>>> globals()
{'__builtins__': {'bytearray': <class 'bytearray'>,...

Module builtins has become the main module. Assignments are added to the
__builtins__ dict.  I am not sure if this is intended or a bug, but if
IDLE is trying to 'recover' from the 'disabling' of the main module, I
think 'Restart Shell ^F6' would be better.

components: IDLE
messages: 73603
nosy: tjreedy
severity: normal
status: open
title: Clearing globals; interpreter -- IDLE difference
versions: Python 3.0

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list