[Tutor] interpreter restarts

Luke Paireepinart rabidpoobear at gmail.com
Tue Jul 17 02:00:53 CEST 2007


Tiger12506 wrote:
>> But there's an exception to that - if you right-click a file in Windoze
>> and 'edit' it,
>> IDLE won't open up its subprocess, and as such, it can't restart the
>> interpreter session because it's running in the same
>> process as IDLE, and to restart the interpreter would mean restarting 
>> IDLE.
>> Boy, that 'edit with idle' thing sure does cause some problems, don't it? 
>> :)
>> -Luke
>>     
>
> Thanks, Luke. I hadn't thought of that. Question: Why won't IDLE open up its 
> subprocess?
>
> This is the command that is in the registry concerning the Edit with IDLE 
> menu.
> "C:\Python25\pythonw.exe" "C:\Python25\Lib\idlelib\idle.pyw" -n -e "%1"
>
> This is the Target for the shortcut in the Start Menu (Note: the Target box 
> was disabled!)
> Python 2.5.1
>
> I thought that this was incredibly strange, so I opened this shortcut in a 
> hex editor to see what was different about this shortcut. (Normally, they 
> have a path in the target box)
>
> What I found surprised me. The title of the file in the hex editor said 
> "python_icon.exe"
> I started laughing maniacally and checked the full path of the file from 
> within the hex editor.
> C:\windows\installer\{31800004-6386-4999-a519-518f2d78d8f0}\python_icon.exe
>
> IDLE is started in two *very* different ways. So my next question was: Can 
> you pass arguments to this python_icon.exe? Simple navigations to that 
> directory and a confirmation... Yuck. You can't even execute it from 
> explorer. A low-level ZwTerminateProcess function from ntdll is called ... 
> Let me try something...
>
> Woah... {31800004-6386-4999-a519-518f2d78d8f0} appears in the registry in 
> alot of places. The Uninstall key for Add/Remove Programs, some weird data 
> thing... Okay, this is beyond me. I don't know the registry or understand 
> CLSIDs very well. Someone who knows Windows inside and out has done a number 
> with the python installer, or at least the msi installer does this all 
> automatically. Interesting. I wonder just how python_icon.exe starts IDLE. 
> If I could figure that out, I could emulate it with the Edit w/Idle menu 
> item and get IDLE to start a subprocess! But how.... any ideas?
>   
It sounds like python_icon.exe is a fake executable that just contains 
the icon for python programs...
hence the name.
You probably stumbled across the path to the icon to use, instead of the 
path that is used when running the 'Edit with IDLE' thing.
Try this:
open an Explorer window, via Start Button -> Run -> explorer {ENTER}
or your favorite method.  Use the My Computer shortcut if you want, 
either way.
Now hit "Alt, t, o" to browse to the Tools -> Folder Options menu setting.
Go to the File Types tab, and scroll down till you find "PY"
click the Advanced button.
You should now see a dialog box with Edit with IDLE listed under actions.
Click Edit when "Edit with IDLE" is selected.
in the "Application used to perform action:" field you should see 
something like this:

"C:\Python24\pythonw.exe" "C:\Python24\Lib\idlelib\idle.pyw" -n -e "%1"

Basically, this is the same as saying:
python idle.py
except it's more verbose because python may not be on your path (and 
pythonw is used instead of python so there's no dos box)
As you will notice, there are some parameters there at the end.
the -n is the one you're interested in .
-n means no subprocess.
Just remove that, and you will have a subprocess on the 'Edit with IDLE' 
feature.
There is some caveat here - it doesn't work correctly on some systems, 
I'm told.
I've never had problems changing this, but I don't recommend it to 
people randomly just in case it were to cause problems for them.
Then I'd feel bad.
But since you asked, I thought I'd give you all the info you need.
HTH,
-Luke
P.S. nice detective skillz ;)


More information about the Tutor mailing list