[IronPython] Execv in the CPython 'os' module
curt at hagenlocher.org
Tue Sep 30 22:34:45 CEST 2008
For IronPython as for CPython running under Windows, the underlying
implementation of the (pure Python) os module is largely contained in the
"nt" module. That's where execv and execve would be if they were
implemented -- which, as you've pointed out, they're not. Yet.
So that's probably where you'd want to "monkey patch" IronPython, possibly
running code like the following from site.py:
# defining these as appropriate
def execv(*args): pass
def execve(*args): pass
nt.execv = execv
nt.execve = execve
Then when you import os, it should pickup these definitions from the nt
There should be an entry in CodePlex that says "implement nt.execv and
nt.execve", but if there's not, please feel free to add one.
On Tue, Sep 30, 2008 at 1:28 PM, CodeKaizen <codekaizen at gmail.com> wrote:
> Hi all -
> I've been baffled by this problem for months, since I can't find it
> addressed anywhere, and have worked around it by using
> System.Diagnostics.Process or switching to powershell, but decided to get to
> the bottom of what is going on.
> I can import the 'os' module, from which I want to use 'execvp' or similar,
> and it appears everything delegates down to 'execv' at some point, and
> that's when I get this error: "NameError: name 'execv' is not defined."
> When I do a 'dir(os)', sure enough, it's not there. Is it looking for the
> system call 'execv' at this point? I'm still a bit green on Python yet, and
> I'm wondering if I can write my own 'execv' function and "attach" it to the
> 'os' module by adding it to the name table or something.
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users