]> granicus.if.org Git - python/commitdiff
#6416: Fix compilation of the select module on Windows, as well as test_subprocess:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 9 Jul 2009 22:37:22 +0000 (22:37 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 9 Jul 2009 22:37:22 +0000 (22:37 +0000)
PIPE_BUF is not defined on Windows, and probably has no meaning there.

Anyway the subprocess module uses another way to perform non-blocking reads (with a thread)

Doc/library/select.rst
Lib/subprocess.py
Lib/test/test_subprocess.py
Modules/selectmodule.c

index 469fbac71e321bcb031649075f8c0721449416cb..7ca9fde4f8f5b73975f7ef3f0b3e3561c379c560 100644 (file)
@@ -105,7 +105,7 @@ The module defines the following:
    Files reported as ready for writing by :func:`select`, :func:`poll` or
    similar interfaces in this module are guaranteed to not block on a write
    of up to :const:`PIPE_BUF` bytes.
-   This value is guaranteed by POSIX to be at least 512.
+   This value is guaranteed by POSIX to be at least 512.  Availability: Unix.
 
    .. versionadded:: 2.7
 
index c8dcb56e21e0de3faa708127d895573acd839c95..a5bb65065a6942bea50b3a6b02274ee24cc60ed5 100644 (file)
@@ -418,6 +418,12 @@ else:
     import fcntl
     import pickle
 
+    # When select or poll has indicated that the file is writable,
+    # we can write up to _PIPE_BUF bytes without risk of blocking.
+    # POSIX defines PIPE_BUF as >= 512.
+    _PIPE_BUF = getattr(select, 'PIPE_BUF', 512)
+
+
 __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call",
            "check_output", "CalledProcessError"]
 
@@ -426,11 +432,6 @@ try:
 except:
     MAXFD = 256
 
-# When select or poll has indicated that the file is writable,
-# we can write up to _PIPE_BUF bytes without risk of blocking.
-# POSIX defines PIPE_BUF as >= 512.
-_PIPE_BUF = getattr(select, 'PIPE_BUF', 512)
-
 _active = []
 
 def _cleanup():
index 5add023944e136beb9dbadbbdfbb0b064302b272..1693c6b445359db46221bcddc52b8237edd03ded 100644 (file)
@@ -769,7 +769,7 @@ class ProcessTestCase(unittest.TestCase):
 
 unit_tests = [ProcessTestCase]
 
-if subprocess._has_poll:
+if getattr(subprocess, '_has_poll', False):
     class ProcessTestCaseNoPoll(ProcessTestCase):
         def setUp(self):
             subprocess._has_poll = False
index a40581270175ffefb03538d500fcc88f861388f3..d8a68c570a10dc3a34f71219d4aa5b7bdb53ad21 100644 (file)
@@ -1746,7 +1746,9 @@ initselect(void)
        Py_INCREF(SelectError);
        PyModule_AddObject(m, "error", SelectError);
 
+#ifdef PIPE_BUF
        PyModule_AddIntConstant(m, "PIPE_BUF", PIPE_BUF);
+#endif
 
 #if defined(HAVE_POLL)
 #ifdef __APPLE__