Dave Yeo | 7 May 2009 06:18

Re: Re: GCC 4.4.0 & binutils v2.19.1 available

On Tue, 05 May 2009 22:01:33 +1000, Andrew MacIntyre wrote:

>- If I understand correctly, Paul's Python builds don't include any
>   significant modifications to standard library modules.  Hence, the
>   script would be using "/bin/sh" as the shell, and failing if it
>   isn't operative.

Actually looking at his patch I see this

+       int unset_emxshell = 0;
        FILE *fp;
        PyObject *f;
        if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode,
&bufsize))
                return NULL;
+       /* a little hack for making sure commands.getstatusoutput works
+        * (ASSUMES that COMSPEC isn't a posix shell.) */
+       if (name[0] == '{' && !getenv("EMXSHELL")) {
+               char path[512];
+               _searchenv("sh.exe", "PATH", path);
+               if (!path[0])
+                       _searchenv("ash.exe", "PATH", path);
+               if (!path[0])
+                       _searchenv("bash.exe", "PATH", path);
+               if (path[0])
+                       unset_emxshell = setenv("EMXSHELL", path, 0) ==
0;
+       }
        Py_BEGIN_ALLOW_THREADS
        fp = popen(name, mode);
(Continue reading)

Andrew MacIntyre | 7 May 2009 12:55
Picon
Picon

Re: Re: GCC 4.4.0 & binutils v2.19.1 available

Dave Yeo wrote:
> On Tue, 05 May 2009 22:01:33 +1000, Andrew MacIntyre wrote:
> 
>> - If I understand correctly, Paul's Python builds don't include any
>>   significant modifications to standard library modules.  Hence, the
>>   script would be using "/bin/sh" as the shell, and failing if it
>>   isn't operative.
> 
> Actually looking at his patch I see this
> 
> +       int unset_emxshell = 0;
>         FILE *fp;
>         PyObject *f;
>         if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode,
> &bufsize))
>                 return NULL;
> +       /* a little hack for making sure commands.getstatusoutput works
> +        * (ASSUMES that COMSPEC isn't a posix shell.) */
> +       if (name[0] == '{' && !getenv("EMXSHELL")) {
> +               char path[512];
> +               _searchenv("sh.exe", "PATH", path);
> +               if (!path[0])
> +                       _searchenv("ash.exe", "PATH", path);
> +               if (!path[0])
> +                       _searchenv("bash.exe", "PATH", path);
> +               if (path[0])
> +                       unset_emxshell = setenv("EMXSHELL", path, 0) ==
> 0;
> +       }
>         Py_BEGIN_ALLOW_THREADS
(Continue reading)

Andrew MacIntyre | 8 May 2009 13:52
Picon
Picon

Re: Re: GCC 4.4.0 & binutils v2.19.1 available

Andrew MacIntyre wrote:

> That patch only affects os.popen().  The fate script is using the
> subprocess module, which (currently, and in the absence of mods by Paul)
> on non-Windows platforms always does an explicit fork() and uses
> "/bin/sh -c" if a shell is requested (which the fate script does).
> os.pipe() is called to create the required pipes.  See subprocess.py in
> the Lib directory.

Hmmm... re-reading what I wrote, being a bit more specific would have
been a bit more helpful:  the interesting bit is the _execute_child
method (POSIX version) in subprocess.py.

Andrew.

--

-- 
-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac <at> bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac <at> pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia

Gmane