[Python-checkins] r73916 - in python/trunk: Doc/library/select.rst Lib/subprocess.py Lib/test/test_subprocess.py Modules/selectmodule.c

amaury.forgeotdarc python-checkins at python.org
Fri Jul 10 00:37:27 CEST 2009


Author: amaury.forgeotdarc
Date: Fri Jul 10 00:37:22 2009
New Revision: 73916

Log:
#6416: Fix compilation of the select module on Windows, as well as test_subprocess:
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)


Modified:
   python/trunk/Doc/library/select.rst
   python/trunk/Lib/subprocess.py
   python/trunk/Lib/test/test_subprocess.py
   python/trunk/Modules/selectmodule.c

Modified: python/trunk/Doc/library/select.rst
==============================================================================
--- python/trunk/Doc/library/select.rst	(original)
+++ python/trunk/Doc/library/select.rst	Fri Jul 10 00:37:22 2009
@@ -105,7 +105,7 @@
    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
 

Modified: python/trunk/Lib/subprocess.py
==============================================================================
--- python/trunk/Lib/subprocess.py	(original)
+++ python/trunk/Lib/subprocess.py	Fri Jul 10 00:37:22 2009
@@ -418,6 +418,12 @@
     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 @@
 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():

Modified: python/trunk/Lib/test/test_subprocess.py
==============================================================================
--- python/trunk/Lib/test/test_subprocess.py	(original)
+++ python/trunk/Lib/test/test_subprocess.py	Fri Jul 10 00:37:22 2009
@@ -769,7 +769,7 @@
 
 unit_tests = [ProcessTestCase]
 
-if subprocess._has_poll:
+if getattr(subprocess, '_has_poll', False):
     class ProcessTestCaseNoPoll(ProcessTestCase):
         def setUp(self):
             subprocess._has_poll = False

Modified: python/trunk/Modules/selectmodule.c
==============================================================================
--- python/trunk/Modules/selectmodule.c	(original)
+++ python/trunk/Modules/selectmodule.c	Fri Jul 10 00:37:22 2009
@@ -1746,7 +1746,9 @@
 	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__


More information about the Python-checkins mailing list