summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-07-09 22:37:22 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-07-09 22:37:22 +0000
commitce32eb7406baf7a51f7764a7c6ce245dd99dabe9 (patch)
treedf9d9312bf0cbf7d2dd962e4b8d2299640af24b5
parentb0c828ae4a18591b135357c47b1baeecb02f3a5e (diff)
downloadcpython-git-ce32eb7406baf7a51f7764a7c6ce245dd99dabe9.tar.gz
#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)
-rw-r--r--Doc/library/select.rst2
-rw-r--r--Lib/subprocess.py11
-rw-r--r--Lib/test/test_subprocess.py2
-rw-r--r--Modules/selectmodule.c2
4 files changed, 10 insertions, 7 deletions
diff --git a/Doc/library/select.rst b/Doc/library/select.rst
index 469fbac71e..7ca9fde4f8 100644
--- a/Doc/library/select.rst
+++ b/Doc/library/select.rst
@@ -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
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index c8dcb56e21..a5bb65065a 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -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():
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 5add023944..1693c6b445 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -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
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index a405812701..d8a68c570a 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -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__