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

Discussion in 'Python' started by gen_tricomi, May 3, 2006.

  1. gen_tricomi

    gen_tricomi Guest

    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

    f
    >>> 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.

     
    gen_tricomi, May 3, 2006
    #1
    1. Advertising

  2. gen_tricomi

    nick Guest

    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
    stdout:

    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
    window:

    >>> 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)
     
    nick, May 4, 2006
    #2
    1. Advertising

  3. gen_tricomi

    gen_tricomi Guest

    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
     
    gen_tricomi, May 23, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joshua Beall
    Replies:
    26
    Views:
    223,273
    AndreiKaa
    Jun 29, 2007
  2. Lonnie Princehouse

    reload fails if module not in sys.path

    Lonnie Princehouse, Oct 21, 2005, in forum: Python
    Replies:
    4
    Views:
    560
    Lonnie Princehouse
    Oct 21, 2005
  3. =?iso-8859-9?q?S=F6nmez_Kartal?=

    reload(sys)

    =?iso-8859-9?q?S=F6nmez_Kartal?=, Aug 31, 2007, in forum: Python
    Replies:
    11
    Views:
    658
    =?iso-8859-1?q?S=F6nmez_Kartal?=
    Sep 6, 2007
  4. Stefan Mueller
    Replies:
    4
    Views:
    334
    Stefan Mueller
    Nov 5, 2005
  5. ViLco
    Replies:
    4
    Views:
    1,825
    ViLco
    Oct 20, 2011
Loading...

Share This Page