Commit Graph

111 Commits

Author SHA1 Message Date
Gregory P. Smith a80f4fb048 Fix "BytesWarning: str() on a bytes instance" 2010-12-14 15:23:02 +00:00
Gregory P. Smith e85db2bbb8 Issue #1731717: Fixed the problem where subprocess.wait() could cause an
OSError exception when The OS had been told to ignore SIGCLD in our process
or otherwise not wait for exiting child processes.
2010-12-14 14:38:00 +00:00
Gregory P. Smith 8edd99d085 Issue #6559: fix the subprocess.Popen pass_fds implementation. Add a unittest.
Issue #7213: Change the close_fds default on Windows to better match the new
default on POSIX.  True when possible (False if stdin/stdout/stderr are
supplied).

Update the documentation to reflect all of the above.
2010-12-14 13:43:30 +00:00
Gregory P. Smith 51ee270876 issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
the C code, using pipe2() when available.  Adds unittests for close_fds and
cloexec behaviors.
2010-12-13 07:59:39 +00:00
Gregory P. Smith f560485388 Get rid of the close_fds DeprecationWarning. Changes the default on a per
platform basis.  It remains False on Windows and changes to True on all
other platforms (POSIX).  Based on python-dev discussion and
http://bugs.python.org/issue7213.
2010-12-13 06:45:02 +00:00
Gregory P. Smith b4162305bb refactor the warning test. 2010-12-04 09:59:52 +00:00
Gregory P. Smith d23047b62c issue7213 + issue2320: Cause a DeprecationWarning if the close_fds argument is
not passed to subprocess.Popen as the default value will be changing in a
future Python to the safer and more often desired value of True.

DeprecationWarnings that show up in a lot of existing code are controversial
and have caused pain in the past.  I'd like to leave this on for 3.2 beta1 and
see how things go.  We can remove the warning if it is deemed too noisy during
any betas.  (case study: the md5 and sha module DeprecationWarnings are loathed
around the world as those modules were never going to be removed in 2.x and
2to3 has a fixer for code that uses them)
2010-12-04 09:10:44 +00:00
Brian Curtin 79cdb661f5 Fix #10554. Added context manager support to Popen objects.
Added a few common Popen uses to the tests like we've done for a few other
instances of adding context managers. Eventually the entire test suite
could be converted to use the context manager format.
2010-12-03 02:46:02 +00:00
Ezio Melotti b3aedd4862 #9424: Replace deprecated assert* methods in the Python test suite. 2010-11-20 19:04:17 +00:00
Benjamin Peterson 5f78040057 add filename to ENOENT message #4925 2010-11-20 18:07:52 +00:00
Brian Curtin 19a5379c97 Fix a number of ResourceWarnings on Windows due to open pipes. 2010-11-05 17:09:05 +00:00
Brian Curtin 3c6a951cfb Add cleanups to stdout/stderr pipes to remove ResourceWarnings. 2010-11-05 03:58:52 +00:00
Benjamin Peterson cc221b2411 close some more files 2010-10-31 02:06:21 +00:00
Victor Stinner f6782ac0b6 test_subprocess: use surrogateescape error handler to write shell scripts
test_args_string() and test_call_string() create shell scripts including the
path to the Python executable: use surrogateescape to encode paths including
surrogate characters.
2010-10-16 23:46:43 +00:00
Victor Stinner 89f3ad10d2 test_subprocess doesn't need to C locale to test os.environb
Improve also the comment to explain why C locale is needed to test os.environ.
2010-10-14 10:43:31 +00:00
Victor Stinner ebc78d23ef test_subprocess: use C locale to get ascii locale encoding 2010-10-14 10:38:17 +00:00
Victor Stinner 8f6b6b0cc3 Issue #9992: Remove PYTHONFSENCODING environment variable. 2010-10-13 22:02:27 +00:00
Antoine Pitrou a4024e2dd5 Make _kill_process more robust under Windows too (see issue #8432) 2010-09-24 18:57:01 +00:00
Antoine Pitrou 3d8580f690 Try a more robust implementation of _kill_process 2010-09-20 01:33:21 +00:00
Antoine Pitrou 84e751a442 Try to fix buildbot failure (#9902) 2010-09-20 00:12:19 +00:00
Antoine Pitrou fedd481596 Try to make signal-sending tests in test_subprocess more robust on slow machines 2010-09-19 23:06:53 +00:00
Antoine Pitrou fb8db8f635 Try to fix test_subprocess on "x86 debian parallel 3.x" buildbot 2010-09-19 22:46:05 +00:00
Antoine Pitrou 8db3027e6a Issue #9895: speed up test_subprocess 2010-09-18 22:38:48 +00:00
Antoine Pitrou 679e0f2328 Issue #9894: Do not hardcode ENOENT in test_subprocess.
(GNU/Hurd is not dead)
2010-09-18 17:56:02 +00:00
Brian Curtin d835cf1c84 Fix #9588. Add sys.executable to two shell=True tests. 2010-08-13 20:42:57 +00:00
Tim Golden 126c2960ca #2304: fix incorporating Eric Smith's .format suggestion and tested on Ubuntu as well as Windows 2010-08-11 14:20:40 +00:00
Benjamin Peterson 1a0a737b13 revert r83830, breaks tests on unixes 2010-08-08 19:08:44 +00:00
Tim Golden e3f76168a9 Issue #2304: Add additional quotes when using cmd shell on Windows. Original patch from Gabriel Genellina 2010-08-08 16:17:48 +00:00
Tim Golden af5ac3974b Issue #3210: Ensure stdio handles are closed if CreateProcess fails 2010-08-06 13:03:56 +00:00
Antoine Pitrou 62f68ed31f Factor out stripping of interpreter debug output in test.support.strip_python_stderr() 2010-08-04 11:48:56 +00:00
Ronald Oussoren 102d11a6d6 Workaround for issue 4047: in some configurations of
the Crash Reporter on OSX test_subprocess will trigger
the reporter.

This patch prints a warning when the Crash Reporter will
get triggered intentionally, which should avoid confusing
people.
2010-07-23 09:50:05 +00:00
Stefan Krah 9542cc6eb5 Issue #9265: Incorrect name passed as arg[0] when shell=True
and executable specified.
2010-07-19 14:20:53 +00:00
Jean-Paul Calderone 1ddd4075bf Merged revisions 82075 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r82075 | jean-paul.calderone | 2010-06-18 16:00:17 -0400 (Fri, 18 Jun 2010) | 12 lines

  Revert r60115

  This revision introduced quoting for strings containing | based
  on a misunderstanding of the commonly used quoting rules used
  on Windows.

  | is interpreted by cmd.exe, not by the MS C runtime argv initializer.
  It only needs to be quoted if it is part of an argument passed through
  cmd.exe.

  See issue1300, issue7839, and issue8972.
........
2010-06-18 20:03:54 +00:00
Victor Stinner b369358ee4 Issue #8780: Fix a regression introduced by r78946 in subprocess on Windows
Ensure that stdout / stderr is inherited from the parent if stdout=PIPE /
stderr=PIPE is not used.
2010-05-21 20:13:12 +00:00
Victor Stinner b745a74c99 Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
subprocess.Popen() and os._execvpe() support bytes program name. Add
os.supports_bytes_environ flag: True if the native OS type of the environment
is bytes (eg. False on Windows).
2010-05-18 17:17:23 +00:00
Victor Stinner 84ae118006 Issue #8603: Create a bytes version of os.environ for Unix
Create os.environb mapping and os.getenvb() function, os.unsetenv() encodes str
argument to the file system encoding with the surrogateescape error handler
(instead of utf8/strict) and accepts bytes, and posix.environ keys and values
are bytes.
2010-05-06 22:05:07 +00:00
Victor Stinner ce2d24d549 Fix test_undecodable_env of test_subproces for non-ASCII directory
This test was introduced by r80421 (issue #8391).

The fix: copy the environment variables instead of starting Python in an empty
environement. In an empty environment, the locale is C and Python uses ASCII
for the default file system encoding. The non-ASCII directory will be encoded
using surrogates, but Python3 is unable to load a module or package with a
filename using surrogates.

See issue #8242 for more information about running Python3 with a non-ascii
directory in an empty environement.
2010-04-23 22:55:39 +00:00
Victor Stinner 13bb71c38f Issue #8391: os.execvpe() and os.getenv() supports unicode with surrogates and
bytes strings for environment keys and values
2010-04-23 21:41:56 +00:00
Victor Stinner 4d07804660 Issue #8467: Pure Python implementation of subprocess encodes the error message
using surrogatepass error handler to support surrogates in the message
2010-04-23 19:28:32 +00:00
Florent Xicluna c049d870b5 Merged revisions 79344,79346,79350 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79344 | florent.xicluna | 2010-03-23 15:36:45 +0100 (mar, 23 mar 2010) | 2 lines

  Silence test_subprocess.
........
  r79346 | florent.xicluna | 2010-03-23 16:05:30 +0100 (mar, 23 mar 2010) | 2 lines

  The standard error should be empty when the signal is killed, except on SIGINT.
........
  r79350 | florent.xicluna | 2010-03-23 20:19:16 +0100 (mar, 23 mar 2010) | 2 lines

  The SIGINT signal may happen earlier, during site.py initialization.
........
2010-03-27 22:47:23 +00:00
Gregory P. Smith 32ec9da166 * Fix a refleak when a preexec_fn was supplied (preexec_fn_args_tuple was not
being defref'ed).
* Fixes another potential refleak of a reference to the gc
  module in the unlikely odd case where gc module isenabled or disable calls
  fail.
* Adds a unittest for the above case to verify behavior and lack of leaks.
2010-03-19 16:53:08 +00:00
Gregory P. Smith fb94c5f1e5 * Replaces the internals of the subprocess module from fork through exec on
POSIX systems with a C extension module.  This is required in order for
  the subprocess module to be made thread safe.

  The pure python implementation is retained so that it can continue to be
  used if for some reason the _posixsubprocess extension module is not
  available.

  The unittest executes tests on both code paths to guarantee compatibility.

* Moves PyLong_FromPid and PyLong_AsPid from posixmodule.c into longobject.h.

Code reviewed by jeffrey.yasskin at http://codereview.appspot.com/223077/show
2010-03-14 06:49:55 +00:00
Florent Xicluna 1d1ab9734a Merged revisions 78833 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78833 | florent.xicluna | 2010-03-11 02:50:48 +0100 (jeu, 11 mar 2010) | 2 lines

  Revert r78830: realpath() should really be applied to sys.executable.
........
2010-03-11 01:53:10 +00:00
Florent Xicluna ecf021c7c0 Merged revisions 78830 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78830 | florent.xicluna | 2010-03-11 01:56:59 +0100 (jeu, 11 mar 2010) | 3 lines

  Fix the test_subprocess failure when sys.executable is meaningless: '' or a directory.
  It does not fix #7774.
........
2010-03-11 01:00:26 +00:00
Florent Xicluna 4886d246a8 Merged revisions 78736,78759,78761,78767,78788-78789 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78736 | florent.xicluna | 2010-03-06 20:43:41 +0100 (sam, 06 mar 2010) | 2 lines

  Skip test_send_signal, test_kill, test_terminate on win32 platforms, for 2.7a4 release.
........
  r78759 | florent.xicluna | 2010-03-07 13:21:36 +0100 (dim, 07 mar 2010) | 2 lines

  #2777: Enable test_send_signal, test_terminate and test_kill on win32 platforms.
........
  r78761 | florent.xicluna | 2010-03-07 16:27:39 +0100 (dim, 07 mar 2010) | 4 lines

  Do not fail if returncode is 0 on send_signal/kill/terminate, for win32 platforms.
  Do not hide the KeyboardInterrupt on POSIX platforms.
........
  r78767 | florent.xicluna | 2010-03-07 18:12:23 +0100 (dim, 07 mar 2010) | 2 lines

  #2777: Try hard to make Win7 buildbot happy...
........
  r78788 | florent.xicluna | 2010-03-08 11:58:12 +0100 (lun, 08 mar 2010) | 2 lines

  Fix syntax: "rc != None" -> "rc is not None"
........
  r78789 | florent.xicluna | 2010-03-08 11:59:33 +0100 (lun, 08 mar 2010) | 2 lines

  Replace the stderr logging with assertNotEqual(returncode, 0).
........
2010-03-08 13:27:26 +00:00
Florent Xicluna fadf93a162 Merged revisions 78721 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78721 | florent.xicluna | 2010-03-06 10:54:14 +0100 (sam, 06 mar 2010) | 2 lines

  #2777: Apply same recipe on win32, i.e. do not inherit file handles.
........
2010-03-06 11:52:51 +00:00
Florent Xicluna 0cc3df8d22 Merged revisions 78704 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78704 | florent.xicluna | 2010-03-06 01:16:57 +0100 (sam, 06 mar 2010) | 2 lines

  #2777: Apply same recipe for test_terminate and test_kill, i.e. close or redirect fds.
........
2010-03-06 00:19:38 +00:00
Florent Xicluna 1d8ee3afb8 Merged revisions 78701 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78701 | florent.xicluna | 2010-03-05 20:31:21 +0100 (ven, 05 mar 2010) | 2 lines

  #2777: Handle fds more carefully to try to fix some x86-Linux failures (namely, neal bot and twisted bot).
........
2010-03-05 20:26:54 +00:00
Florent Xicluna b8f22b1498 Merged revisions 78673 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78673 | florent.xicluna | 2010-03-05 02:05:55 +0100 (ven, 05 mar 2010) | 2 lines

  Let's use assertIsNone / assertIsNotNone. It's hype.
........
2010-03-05 01:18:04 +00:00
Florent Xicluna 6f66648508 Remove some debug line... 2010-03-05 01:07:40 +00:00