Bugs item #1105950, was opened at 2005-01-20 08:08
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1105950&group_id=5470

Category: IDLE
Group: Python 2.3
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: imperialfists (imperialfists)
Assigned to: Kurt B. Kaiser (kbk)
Summary: bug with idle's stdout when executing load_source

Initial Comment:
There is a bug in idle caused by load_source, which
switches the stdout of idle to something else.

Here is what I did:
Python 2.3.4 (#1, Nov  2 2004, 11:18:38) 
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1,
ssp-3.3.2-2, pie-8.7.6)] on linux2
[...i leave this out...]
IDLE 1.0.3      
>>> from sys import stdout
>>> print stdout
<idlelib.rpc.RPCProxy instance at 0x407914ac>
>>> print 'a'
a
>>> from imp import load_source
>>> print 'a'
a
>>> print stdout
<idlelib.rpc.RPCProxy instance at 0x407914ac>
>>> m = load_source('bug.py', 'bug.py', open('bug.py'))
>>> print 'a'
>>> print stdout
>>> 

the file 'bug.py' contains the following line:
from types import *

meanwhile i see this on my terminal:
a
<idlelib.rpc.RPCProxy instance at 0x407914ac>

when i type "import bug" or "from bug import *"
everything works fine.
This bug also works (at least for me) if I start idle
from the the "Run Command" dialog under kde, instead of
the terminal.

----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2005-01-23 19:10

Message:
Logged In: YES 
user_id=149084

These low level imp module functions don't just import,
they reload() the module.  This destroys the redirection
of stdin, stdout, stderr that IDLE has set up to work with
Tkinter.

Using IDLE without its subprocess, and with verbose
output:

hydra /home/kbk/PYSRC/Lib/idlelib$ ../../python -v ./PyShell.py -n 
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
[...]

In the IDLE shell:

IDLE 1.2a0      ==== No Subprocess ====
>>> import sys
>>> sys.stdout
<__main__.PseudoFile object at 0x42feac>
>>> reload(sys)
>>> sys.stdout
>>> 

And on the console:
[...]
import sys # previously loaded (sys)
<module 'sys' (built-in)>
<open file '<stdout>', mode 'w' at 0xfa068>

imp.load_source() is incompatible with IDLE.
Please use the high level import statements.

I didn't find any extra files.

----------------------------------------------------------------------

Comment By: imperialfists (imperialfists)
Date: 2005-01-21 03:45

Message:
Logged In: YES 
user_id=1201021

Also i find a file named 'c' in my current working directory.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1105950&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to