<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="margin: 0px; font-size: 11px; font-family: Menlo;">(This post is out of order:  I sent it to the wrong list.  See my earlier post for a workaround for the problem which this post describes.)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">I have determined that it fails here in pythonrun.c in function initstdio():</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    fd = fileno(stdin);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><span style="color: rgb(0, 0, 0);">    </span>/* Under some conditions stdin, stdout and stderr may not be connected</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">     * and fileno() may point to an invalid file descriptor. For example</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">     * GUI apps don't have valid standard streams by default.</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">     */</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    <span style="color: rgb(187, 44, 162);">if</span> (!is_valid_fd(fd)) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">        std = Py_None;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">        Py_INCREF(std);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    <span style="color: rgb(187, 44, 162);">else</span> {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">       std = create_stdio(iomod, fd, <span style="color: rgb(39, 42, 216);">0</span>, <span style="color: rgb(209, 47, 27);">"<stdin>"</span>, encoding, errors);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">       <span style="color: rgb(187, 44, 162);">if</span> (std == <span style="color: rgb(187, 44, 162);">NULL</span>) {  << this is true and it proceeds to return an error and abort</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">I haven’t determined yet why create_stdio fails, or why fileno(stdin) returns a valid fd if there is no stdin for the process on Android?</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">I don’t understand the rationale here: why every process should have a stdin and why the Python interpreter needs to initialize it (especially on Android with PyQt.)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">One comment in the discussion of Python issue 17797 says a workaround is to redirect stdio to a file before calling Py_InitializeEx (and thus initstdio() )</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">Note that issue 17797 has recent comments in the last few days.  The thread says any ‘fix’ for Python (at least in regards Windows VS11 as a culprit) must wait till Python3.5.  The pertinent code in Python seems to have been changed recently.</div></body></html>