problem with reload(sys) (doing reload on the sys module)

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.

    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.

IDLE 1.1.2
>>> import sys
>>> sys.modules.keys()
['tkFileDialog', 'random', 'struct', 'tempfile', 'idlelib.cPickle',
'imp', 'collections', 'zipimport', 'string', 'SocketServer', 'repr',
'idlelib.string', 'idlelib.bdb', 'itertools', 'idlelib.SocketServer',
'ConfigParser', 'signal', 'idlelib.IOBinding', 'threading',
'tkMessageBox', 'idlelib.warnings', 'idlelib.struct',
'idlelib.cStringIO', 'cStringIO', 'locale', 'idlelib.threading',
'idlelib.TreeWidget', 'idlelib.rpc', 'atexit', 'idlelib.re',
'encodings', 'idlelib.RemoteDebugger', 'idlelib.tempfile',
'idlelib.codecs', '_tkinter', 'bdb', 're',
'idlelib.RemoteObjectBrowser', 'ntpath', 'idlelib.imp',
'idlelib.locale', 'idlelib.thread', 'math', 'idlelib.Debugger',
'Tkinter', 'idlelib.traceback', 'idlelib.marshal', 'UserDict', 'Queue',
'idlelib.StackViewer', 'codecs', 'idlelib.copy_reg', '_locale',
'socket', 'thread', 'sre', 'idlelib.time', 'traceback',
'idlelib.socket', 'idlelib.CallTipWindow', 'os', 'marshal',
'idlelib.tkFileDialog', '_sre', '__builtin__', 'select', 'idlelib.os',
'idlelib.ZoomHeight', 'idlelib.ConfigParser', 'errno', '_socket',
'binascii', 'sre_constants', 'types', 'idlelib.__builtin__',
'idlelib.tkMessageBox', 'cPickle', '_codecs', 'encodings.cp1252',
'idlelib.repr', 'idlelib.Queue', 'idlelib.__main__', 'idlelib.sys',
'encodings.aliases', 'exceptions', 'sre_parse', 'FixTk', 'copy_reg',
'sre_compile', '_random', 'site', 'SimpleDialog', '__main__',
'idlelib.types', 'tkCommonDialog', 'strop', 'encodings.codecs',
'encodings.exceptions', 'nt', 'idlelib.linecache', 'stat', '_ssl',
'warnings', 'encodings.types', 'sys', 'idlelib.Tkinter',
'idlelib.CallTips', 'idlelib.configHandler', 'idlelib.WindowList',
'idlelib.SimpleDialog', 'os.path', 'idlelib.ScrolledList',
'idlelib.ObjectBrowser', 'idlelib', 'Tkconstants', 'linecache', 'time',
'idlelib.select', 'idlelib.run']
>>> reload(sys)
>>> sys.modules.keys()
>>> dir()
>>> print 'hello world'
>>> print 'hi nerds'
>>> print 'it just stops here nothing works again'
>>> print 'is this a bug or a feature'
>>> print 'can some one help'
>>> 2 + 4
>>> print 'but when i restart'
>>> print 'everything returns'
>>> import string
>>> string.lowercase
>>> string.lowercase()
>>> print 'let me see if an exception can be thrown'
>>> import nigeria
>>> import lagos
>>> no exception
SyntaxError: invalid syntax
>>> print 'still checks for syntax'
>>> print 'it checks syntax after the second token has been entered'
>>> abracadabra
>>> not
SyntaxError: invalid syntax
>>> print
>>> is
SyntaxError: invalid syntax
>>> print 'syntax check is still working for reserved words'
>>> you
>>> can
>>> check
>>> the
>>> rest
>>> for
SyntaxError: invalid syntax
>>> your
>>> self
>>> print 'i think this IDLE session is self explanatory'

This is not part of the above IDLE session
please mail me if you have any idea what this means.


ogahejini (5)
5/3/2006 5:12:44 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

2 Replies

Similar Articles

[PageSpeed] 40

Looks like a bug (probably in IDLE): when I start IDLE from the command
line, it pops up its interaction window and here is what it says about

IDLE 1.1.2      
>>> import sys
>>> sys.stdout
<idlelib.rpc.RPCProxy instance at 0xb76a490c>

Then I try the reload and I get no output in the interaction

>>> reload(sys)
>>> sys.stdout

After the reload, stdout has been changed to the terminal from which
IDLE got started, so I see the messages there:

<module 'sys' (built-in)>
<open file '<stdout>', mode 'w' at 0xb7b67068>

As you can see, stdout has been redefined (back to the way it would be if
you started Python from the command line, with no IDLE involved).
nick  (nicholas dot dokos at hp dot com)
nobody56 (91)
5/4/2006 4:57:10 PM
hi nick,

have you found any solutions to this problem.
maybe sys module does not need to be reloaded.
may Tim peters and the rest can help us on this

ogahejini (5)
5/23/2006 10:03:43 AM