[Python-3000-checkins] r55335 - in python/branches/p3yk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libos.tex Doc/lib/libpopen2.tex Doc/lib/libsubprocess.tex Lib/popen2.py Lib/test/regrtest.py Lib/test/test___all__.py Lib/test/test_popen2.py Misc/NEWS Misc/cheatsheet

neal.norwitz python-3000-checkins at python.org
Tue May 15 03:03:49 CEST 2007


Author: neal.norwitz
Date: Tue May 15 03:03:38 2007
New Revision: 55335

Removed:
   python/branches/p3yk/Doc/lib/libpopen2.tex
   python/branches/p3yk/Lib/popen2.py
   python/branches/p3yk/Lib/test/test_popen2.py
Modified:
   python/branches/p3yk/Doc/Makefile.deps
   python/branches/p3yk/Doc/lib/lib.tex
   python/branches/p3yk/Doc/lib/libos.tex
   python/branches/p3yk/Doc/lib/libsubprocess.tex
   python/branches/p3yk/Lib/test/regrtest.py
   python/branches/p3yk/Lib/test/test___all__.py
   python/branches/p3yk/Misc/NEWS
   python/branches/p3yk/Misc/cheatsheet
Log:
Get rid of most of popen.  There are still some uses I need to cleanup.

Modified: python/branches/p3yk/Doc/Makefile.deps
==============================================================================
--- python/branches/p3yk/Doc/Makefile.deps	(original)
+++ python/branches/p3yk/Doc/Makefile.deps	Tue May 15 03:03:38 2007
@@ -270,7 +270,6 @@
 	lib/libimaplib.tex \
 	lib/libpoplib.tex \
 	lib/libcalendar.tex \
-	lib/libpopen2.tex \
 	lib/libbisect.tex \
 	lib/libcollections.tex \
 	lib/libheapq.tex \

Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex	(original)
+++ python/branches/p3yk/Doc/lib/lib.tex	Tue May 15 03:03:38 2007
@@ -280,7 +280,6 @@
 \input{libsubprocess}
 \input{libsocket}
 \input{libsignal}
-\input{libpopen2}
 \input{libasyncore}
 \input{libasynchat}
 

Modified: python/branches/p3yk/Doc/lib/libos.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libos.tex	(original)
+++ python/branches/p3yk/Doc/lib/libos.tex	Tue May 15 03:03:38 2007
@@ -1513,9 +1513,6 @@
 \end{funcdesc}
 
 \begin{funcdescni}{popen}{\unspecified}
-\funclineni{popen2}{\unspecified}
-\funclineni{popen3}{\unspecified}
-\funclineni{popen4}{\unspecified}
 Run child processes, returning opened pipes for communications.  These
 functions are described in section \ref{os-newstreams}.
 \end{funcdescni}

Deleted: /python/branches/p3yk/Doc/lib/libpopen2.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libpopen2.tex	Tue May 15 03:03:38 2007
+++ (empty file)
@@ -1,190 +0,0 @@
-\section{\module{popen2} ---
-         Subprocesses with accessible I/O streams}
-
-\declaremodule{standard}{popen2}
-\modulesynopsis{Subprocesses with accessible standard I/O streams.}
-\sectionauthor{Drew Csillag}{drew_csillag at geocities.com}
-
-\deprecated{2.6}{This module is obsolete.  Use the \module{subprocess} module.}
-
-This module allows you to spawn processes and connect to their
-input/output/error pipes and obtain their return codes under
-\UNIX{} and Windows.
-
-The \module{subprocess} module provides more powerful facilities for
-spawning new processes and retrieving their results.  Using the
-\module{subprocess} module is preferable to using the \module{popen2}
-module.
-
-The primary interface offered by this module is a trio of factory
-functions.  For each of these, if \var{bufsize} is specified, 
-it specifies the buffer size for the I/O pipes.  \var{mode}, if
-provided, should be the string \code{'b'} or \code{'t'}; on Windows
-this is needed to determine whether the file objects should be opened
-in binary or text mode.  The default value for \var{mode} is
-\code{'t'}.
-
-On \UNIX, \var{cmd} may be a sequence, in which case arguments will be passed
-directly to the program without shell intervention (as with
-\function{os.spawnv()}). If \var{cmd} is a string it will be passed to the
-shell (as with \function{os.system()}).
-
-The only way to retrieve the return codes for the child processes is
-by using the \method{poll()} or \method{wait()} methods on the
-\class{Popen3} and \class{Popen4} classes; these are only available on
-\UNIX.  This information is not available when using the
-\function{popen2()}, \function{popen3()}, and \function{popen4()}
-functions, or the equivalent functions in the \refmodule{os} module.
-(Note that the tuples returned by the \refmodule{os} module's functions
-are in a different order from the ones returned by the \module{popen2}
-module.)
-
-\begin{funcdesc}{popen2}{cmd\optional{, bufsize\optional{, mode}}}
-Executes \var{cmd} as a sub-process.  Returns the file objects
-\code{(\var{child_stdout}, \var{child_stdin})}.
-\end{funcdesc}
-
-\begin{funcdesc}{popen3}{cmd\optional{, bufsize\optional{, mode}}}
-Executes \var{cmd} as a sub-process.  Returns the file objects
-\code{(\var{child_stdout}, \var{child_stdin}, \var{child_stderr})}.
-\end{funcdesc}
-
-\begin{funcdesc}{popen4}{cmd\optional{, bufsize\optional{, mode}}}
-Executes \var{cmd} as a sub-process.  Returns the file objects
-\code{(\var{child_stdout_and_stderr}, \var{child_stdin})}.
-\versionadded{2.0}
-\end{funcdesc}
-
-
-On \UNIX, a class defining the objects returned by the factory
-functions is also available.  These are not used for the Windows
-implementation, and are not available on that platform.
-
-\begin{classdesc}{Popen3}{cmd\optional{, capturestderr\optional{, bufsize}}}
-This class represents a child process.  Normally, \class{Popen3}
-instances are created using the \function{popen2()} and
-\function{popen3()} factory functions described above.
-
-If not using one of the helper functions to create \class{Popen3}
-objects, the parameter \var{cmd} is the shell command to execute in a
-sub-process.  The \var{capturestderr} flag, if true, specifies that
-the object should capture standard error output of the child process.
-The default is false.  If the \var{bufsize} parameter is specified, it
-specifies the size of the I/O buffers to/from the child process.
-\end{classdesc}
-
-\begin{classdesc}{Popen4}{cmd\optional{, bufsize}}
-Similar to \class{Popen3}, but always captures standard error into the
-same file object as standard output.  These are typically created
-using \function{popen4()}.
-\versionadded{2.0}
-\end{classdesc}
-
-\subsection{Popen3 and Popen4 Objects \label{popen3-objects}}
-
-Instances of the \class{Popen3} and \class{Popen4} classes have the
-following methods:
-
-\begin{methoddesc}[Popen3]{poll}{}
-Returns \code{-1} if child process hasn't completed yet, or its return 
-code otherwise.
-\end{methoddesc}
-
-\begin{methoddesc}[Popen3]{wait}{}
-Waits for and returns the status code of the child process.  The
-status code encodes both the return code of the process and
-information about whether it exited using the \cfunction{exit()}
-system call or died due to a signal.  Functions to help interpret the
-status code are defined in the \refmodule{os} module; see section
-\ref{os-process} for the \function{W\var{*}()} family of functions.
-\end{methoddesc}
-
-
-The following attributes are also available: 
-
-\begin{memberdesc}[Popen3]{fromchild}
-A file object that provides output from the child process.  For
-\class{Popen4} instances, this will provide both the standard output
-and standard error streams.
-\end{memberdesc}
-
-\begin{memberdesc}[Popen3]{tochild}
-A file object that provides input to the child process.
-\end{memberdesc}
-
-\begin{memberdesc}[Popen3]{childerr}
-A file object that provides error output from the child process, if
-\var{capturestderr} was true for the constructor, otherwise
-\code{None}.  This will always be \code{None} for \class{Popen4}
-instances.
-\end{memberdesc}
-
-\begin{memberdesc}[Popen3]{pid}
-The process ID of the child process.
-\end{memberdesc}
-
-
-\subsection{Flow Control Issues \label{popen2-flow-control}}
-
-Any time you are working with any form of inter-process communication,
-control flow needs to be carefully thought out.  This remains the case
-with the file objects provided by this module (or the \refmodule{os}
-module equivalents).
-
-% Example explanation and suggested work-arounds substantially stolen
-% from Martin von Löwis:
-% http://mail.python.org/pipermail/python-dev/2000-September/009460.html
-
-When reading output from a child process that writes a lot of data to
-standard error while the parent is reading from the child's standard
-output, a deadlock can occur.  A similar situation can occur with other
-combinations of reads and writes.  The essential factors are that more
-than \constant{_PC_PIPE_BUF} bytes are being written by one process in
-a blocking fashion, while the other process is reading from the other
-process, also in a blocking fashion.
-
-There are several ways to deal with this situation.
-
-The simplest application change, in many cases, will be to follow this
-model in the parent process:
-
-\begin{verbatim}
-import popen2
-
-r, w, e = popen2.popen3('python slave.py')
-e.readlines()
-r.readlines()
-r.close()
-e.close()
-w.close()
-\end{verbatim}
-
-with code like this in the child:
-
-\begin{verbatim}
-import os
-import sys
-
-# note that each of these print statements
-# writes a single long string
-
-print >>sys.stderr, 400 * 'this is a test\n'
-os.close(sys.stderr.fileno())
-print >>sys.stdout, 400 * 'this is another test\n'
-\end{verbatim}
-
-In particular, note that \code{sys.stderr} must be closed after
-writing all data, or \method{readlines()} won't return.  Also note
-that \function{os.close()} must be used, as \code{sys.stderr.close()}
-won't close \code{stderr} (otherwise assigning to \code{sys.stderr}
-will silently close it, so no further errors can be printed).
-
-Applications which need to support a more general approach should
-integrate I/O over pipes with their \function{select()} loops, or use
-separate threads to read each of the individual files provided by
-whichever \function{popen*()} function or \class{Popen*} class was
-used.
-
-\begin{seealso}
-  \seemodule{subprocess}{Module for spawning and managing subprocesses.}
-\end{seealso}

Modified: python/branches/p3yk/Doc/lib/libsubprocess.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libsubprocess.tex	(original)
+++ python/branches/p3yk/Doc/lib/libsubprocess.tex	Tue May 15 03:03:38 2007
@@ -15,8 +15,6 @@
 \begin{verbatim}
 os.system
 os.spawn*
-os.popen*
-popen2.*
 commands.*
 \end{verbatim}
 
@@ -335,68 +333,3 @@
 ==>
 pipe = Popen(cmd, shell=True, bufsize=bufsize, stdin=PIPE).stdin
 \end{verbatim}
-
-\begin{verbatim}
-(child_stdin, child_stdout) = os.popen2(cmd, mode, bufsize)
-==>
-p = Popen(cmd, shell=True, bufsize=bufsize,
-          stdin=PIPE, stdout=PIPE, close_fds=True)
-(child_stdin, child_stdout) = (p.stdin, p.stdout)
-\end{verbatim}
-
-\begin{verbatim}
-(child_stdin,
- child_stdout,
- child_stderr) = os.popen3(cmd, mode, bufsize)
-==>
-p = Popen(cmd, shell=True, bufsize=bufsize,
-          stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
-(child_stdin,
- child_stdout,
- child_stderr) = (p.stdin, p.stdout, p.stderr)
-\end{verbatim}
-
-\begin{verbatim}
-(child_stdin, child_stdout_and_stderr) = os.popen4(cmd, mode, bufsize)
-==>
-p = Popen(cmd, shell=True, bufsize=bufsize,
-          stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
-(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
-\end{verbatim}
-
-\subsubsection{Replacing popen2.*}
-
-\note{If the cmd argument to popen2 functions is a string, the command
-is executed through /bin/sh.  If it is a list, the command is directly
-executed.}
-
-\begin{verbatim}
-(child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode)
-==>
-p = Popen(["somestring"], shell=True, bufsize=bufsize,
-          stdin=PIPE, stdout=PIPE, close_fds=True)
-(child_stdout, child_stdin) = (p.stdout, p.stdin)
-\end{verbatim}
-
-\begin{verbatim}
-(child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode)
-==>
-p = Popen(["mycmd", "myarg"], bufsize=bufsize,
-          stdin=PIPE, stdout=PIPE, close_fds=True)
-(child_stdout, child_stdin) = (p.stdout, p.stdin)
-\end{verbatim}
-
-The popen2.Popen3 and popen2.Popen4 basically works as subprocess.Popen,
-except that:
-
-\begin{itemize}
-\item subprocess.Popen raises an exception if the execution fails
-
-\item the \var{capturestderr} argument is replaced with the \var{stderr}
-      argument.
-
-\item stdin=PIPE and stdout=PIPE must be specified.
-
-\item popen2 closes all file descriptors by default, but you have to
-      specify close_fds=True with subprocess.Popen.
-\end{itemize}

Deleted: /python/branches/p3yk/Lib/popen2.py
==============================================================================
--- /python/branches/p3yk/Lib/popen2.py	Tue May 15 03:03:38 2007
+++ (empty file)
@@ -1,205 +0,0 @@
-"""Spawn a command with pipes to its stdin, stdout, and optionally stderr.
-
-The normal os.popen(cmd, mode) call spawns a shell command and provides a
-file interface to just the input or output of the process depending on
-whether mode is 'r' or 'w'.  This module provides the functions popen2(cmd)
-and popen3(cmd) which return two or three pipes to the spawned command.
-"""
-
-import os
-import sys
-import warnings
-warnings.warn("The popen2 module is deprecated.  Use the subprocess module.",
-              DeprecationWarning, stacklevel=2)
-
-__all__ = ["popen2", "popen3", "popen4"]
-
-try:
-    MAXFD = os.sysconf('SC_OPEN_MAX')
-except (AttributeError, ValueError):
-    MAXFD = 256
-
-_active = []
-
-def _cleanup():
-    for inst in _active[:]:
-        if inst.poll(_deadstate=sys.maxint) >= 0:
-            try:
-                _active.remove(inst)
-            except ValueError:
-                # This can happen if two threads create a new Popen instance.
-                # It's harmless that it was already removed, so ignore.
-                pass
-
-class Popen3:
-    """Class representing a child process.  Normally instances are created
-    by the factory functions popen2() and popen3()."""
-
-    sts = -1                    # Child not completed yet
-
-    def __init__(self, cmd, capturestderr=False, bufsize=-1):
-        """The parameter 'cmd' is the shell command to execute in a
-        sub-process.  On UNIX, 'cmd' may be a sequence, in which case arguments
-        will be passed directly to the program without shell intervention (as
-        with os.spawnv()).  If 'cmd' is a string it will be passed to the shell
-        (as with os.system()).   The 'capturestderr' flag, if true, specifies
-        that the object should capture standard error output of the child
-        process.  The default is false.  If the 'bufsize' parameter is
-        specified, it specifies the size of the I/O buffers to/from the child
-        process."""
-        _cleanup()
-        self.cmd = cmd
-        p2cread, p2cwrite = os.pipe()
-        c2pread, c2pwrite = os.pipe()
-        if capturestderr:
-            errout, errin = os.pipe()
-        self.pid = os.fork()
-        if self.pid == 0:
-            # Child
-            os.dup2(p2cread, 0)
-            os.dup2(c2pwrite, 1)
-            if capturestderr:
-                os.dup2(errin, 2)
-            self._run_child(cmd)
-        os.close(p2cread)
-        self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
-        os.close(c2pwrite)
-        self.fromchild = os.fdopen(c2pread, 'r', bufsize)
-        if capturestderr:
-            os.close(errin)
-            self.childerr = os.fdopen(errout, 'r', bufsize)
-        else:
-            self.childerr = None
-
-    def __del__(self):
-        # In case the child hasn't been waited on, check if it's done.
-        self.poll(_deadstate=sys.maxint)
-        if self.sts < 0:
-            if _active is not None:
-                # Child is still running, keep us alive until we can wait on it.
-                _active.append(self)
-
-    def _run_child(self, cmd):
-        if isinstance(cmd, basestring):
-            cmd = ['/bin/sh', '-c', cmd]
-        for i in range(3, MAXFD):
-            try:
-                os.close(i)
-            except OSError:
-                pass
-        try:
-            os.execvp(cmd[0], cmd)
-        finally:
-            os._exit(1)
-
-    def poll(self, _deadstate=None):
-        """Return the exit status of the child process if it has finished,
-        or -1 if it hasn't finished yet."""
-        if self.sts < 0:
-            try:
-                pid, sts = os.waitpid(self.pid, os.WNOHANG)
-                # pid will be 0 if self.pid hasn't terminated
-                if pid == self.pid:
-                    self.sts = sts
-            except os.error:
-                if _deadstate is not None:
-                    self.sts = _deadstate
-        return self.sts
-
-    def wait(self):
-        """Wait for and return the exit status of the child process."""
-        if self.sts < 0:
-            pid, sts = os.waitpid(self.pid, 0)
-            # This used to be a test, but it is believed to be
-            # always true, so I changed it to an assertion - mvl
-            assert pid == self.pid
-            self.sts = sts
-        return self.sts
-
-
-class Popen4(Popen3):
-    childerr = None
-
-    def __init__(self, cmd, bufsize=-1):
-        _cleanup()
-        self.cmd = cmd
-        p2cread, p2cwrite = os.pipe()
-        c2pread, c2pwrite = os.pipe()
-        self.pid = os.fork()
-        if self.pid == 0:
-            # Child
-            os.dup2(p2cread, 0)
-            os.dup2(c2pwrite, 1)
-            os.dup2(c2pwrite, 2)
-            self._run_child(cmd)
-        os.close(p2cread)
-        self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
-        os.close(c2pwrite)
-        self.fromchild = os.fdopen(c2pread, 'r', bufsize)
-
-
-if sys.platform[:3] == "win" or sys.platform == "os2emx":
-    # Some things don't make sense on non-Unix platforms.
-    del Popen3, Popen4
-
-    def popen2(cmd, bufsize=-1, mode='t'):
-        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
-        be a sequence, in which case arguments will be passed directly to the
-        program without shell intervention (as with os.spawnv()). If 'cmd' is a
-        string it will be passed to the shell (as with os.system()). If
-        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
-        file objects (child_stdout, child_stdin) are returned."""
-        w, r = os.popen2(cmd, mode, bufsize)
-        return r, w
-
-    def popen3(cmd, bufsize=-1, mode='t'):
-        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
-        be a sequence, in which case arguments will be passed directly to the
-        program without shell intervention (as with os.spawnv()). If 'cmd' is a
-        string it will be passed to the shell (as with os.system()). If
-        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
-        file objects (child_stdout, child_stdin, child_stderr) are returned."""
-        w, r, e = os.popen3(cmd, mode, bufsize)
-        return r, w, e
-
-    def popen4(cmd, bufsize=-1, mode='t'):
-        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
-        be a sequence, in which case arguments will be passed directly to the
-        program without shell intervention (as with os.spawnv()). If 'cmd' is a
-        string it will be passed to the shell (as with os.system()). If
-        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
-        file objects (child_stdout_stderr, child_stdin) are returned."""
-        w, r = os.popen4(cmd, mode, bufsize)
-        return r, w
-else:
-    def popen2(cmd, bufsize=-1, mode='t'):
-        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
-        be a sequence, in which case arguments will be passed directly to the
-        program without shell intervention (as with os.spawnv()). If 'cmd' is a
-        string it will be passed to the shell (as with os.system()). If
-        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
-        file objects (child_stdout, child_stdin) are returned."""
-        inst = Popen3(cmd, False, bufsize)
-        return inst.fromchild, inst.tochild
-
-    def popen3(cmd, bufsize=-1, mode='t'):
-        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
-        be a sequence, in which case arguments will be passed directly to the
-        program without shell intervention (as with os.spawnv()). If 'cmd' is a
-        string it will be passed to the shell (as with os.system()). If
-        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
-        file objects (child_stdout, child_stdin, child_stderr) are returned."""
-        inst = Popen3(cmd, True, bufsize)
-        return inst.fromchild, inst.tochild, inst.childerr
-
-    def popen4(cmd, bufsize=-1, mode='t'):
-        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
-        be a sequence, in which case arguments will be passed directly to the
-        program without shell intervention (as with os.spawnv()). If 'cmd' is a
-        string it will be passed to the shell (as with os.system()). If
-        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
-        file objects (child_stdout_stderr, child_stdin) are returned."""
-        inst = Popen4(cmd, bufsize)
-        return inst.fromchild, inst.tochild
-
-    __all__.extend(["Popen3", "Popen4"])

Modified: python/branches/p3yk/Lib/test/regrtest.py
==============================================================================
--- python/branches/p3yk/Lib/test/regrtest.py	(original)
+++ python/branches/p3yk/Lib/test/regrtest.py	Tue May 15 03:03:38 2007
@@ -887,7 +887,6 @@
         test_ossaudiodev
         test_poll
         test_popen
-        test_popen2
         test_posix
         test_pty
         test_pwd
@@ -986,7 +985,6 @@
         test_ntpath
         test_openpty
         test_poll
-        test_popen2
         test_pty
         test_pwd
         test_strop
@@ -1062,7 +1060,6 @@
         test_mmap
         test_nis
         test_poll
-        test_popen2
         test_resource
         test_sqlite
         test_startfile

Modified: python/branches/p3yk/Lib/test/test___all__.py
==============================================================================
--- python/branches/p3yk/Lib/test/test___all__.py	(original)
+++ python/branches/p3yk/Lib/test/test___all__.py	Tue May 15 03:03:38 2007
@@ -7,8 +7,6 @@
                         "the gopherlib module is deprecated",
                         DeprecationWarning,
                         "<string>")
-warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
-                        DeprecationWarning)
 
 class AllTest(unittest.TestCase):
 
@@ -112,7 +110,6 @@
         self.check_all("pickle")
         self.check_all("pickletools")
         self.check_all("pipes")
-        self.check_all("popen2")
         self.check_all("poplib")
         self.check_all("posixpath")
         self.check_all("pprint")

Deleted: /python/branches/p3yk/Lib/test/test_popen2.py
==============================================================================
--- /python/branches/p3yk/Lib/test/test_popen2.py	Tue May 15 03:03:38 2007
+++ (empty file)
@@ -1,98 +0,0 @@
-#! /usr/bin/env python
-"""Test script for popen2.py"""
-
-import warnings
-warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
-                        DeprecationWarning)
-warnings.filterwarnings("ignore", "os\.popen. is deprecated.*",
-                        DeprecationWarning)
-
-import os
-import sys
-import unittest
-import popen2
-
-from test.test_support import TestSkipped, run_unittest, reap_children
-
-if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos':
-    #  Locks get messed up or something.  Generally we're supposed
-    #  to avoid mixing "posix" fork & exec with native threads, and
-    #  they may be right about that after all.
-    raise TestSkipped("popen2() doesn't work on " + sys.platform)
-
-# if we don't have os.popen, check that
-# we have os.fork.  if not, skip the test
-# (by raising an ImportError)
-try:
-    from os import popen
-    del popen
-except ImportError:
-    from os import fork
-    del fork
-
-class Popen2Test(unittest.TestCase):
-    cmd = "cat"
-    if os.name == "nt":
-        cmd = "more"
-    teststr = "ab cd\n"
-    # "more" doesn't act the same way across Windows flavors,
-    # sometimes adding an extra newline at the start or the
-    # end.  So we strip whitespace off both ends for comparison.
-    expected = teststr.strip()
-
-    def setUp(self):
-        popen2._cleanup()
-        # When the test runs, there shouldn't be any open pipes
-        self.assertFalse(popen2._active, "Active pipes when test starts" +
-            repr([c.cmd for c in popen2._active]))
-
-    def tearDown(self):
-        for inst in popen2._active:
-            inst.wait()
-        popen2._cleanup()
-        self.assertFalse(popen2._active, "_active not empty")
-        reap_children()
-
-    def validate_output(self, teststr, expected_out, r, w, e=None):
-        w.write(teststr)
-        w.close()
-        got = r.read()
-        self.assertEquals(expected_out, got.strip(), "wrote %r read %r" %
-                          (teststr, got))
-
-        if e is not None:
-            got = e.read()
-            self.assertFalse(got, "unexpected %r on stderr" % got)
-
-    def test_popen2(self):
-        r, w = popen2.popen2(self.cmd)
-        self.validate_output(self.teststr, self.expected, r, w)
-
-    def test_popen3(self):
-        if os.name == 'posix':
-            r, w, e = popen2.popen3([self.cmd])
-            self.validate_output(self.teststr, self.expected, r, w, e)
-
-        r, w, e = popen2.popen3(self.cmd)
-        self.validate_output(self.teststr, self.expected, r, w, e)
-
-    def test_os_popen2(self):
-        # same test as test_popen2(), but using the os.popen*() API
-        w, r = os.popen2(self.cmd)
-        self.validate_output(self.teststr, self.expected, r, w)
-
-    def test_os_popen3(self):
-        # same test as test_popen3(), but using the os.popen*() API
-        if os.name == 'posix':
-            w, r, e = os.popen3([self.cmd])
-            self.validate_output(self.teststr, self.expected, r, w, e)
-
-        w, r, e = os.popen3(self.cmd)
-        self.validate_output(self.teststr, self.expected, r, w, e)
-
-
-def test_main():
-    run_unittest(Popen2Test)
-
-if __name__ == "__main__":
-    test_main()

Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS	(original)
+++ python/branches/p3yk/Misc/NEWS	Tue May 15 03:03:38 2007
@@ -180,8 +180,10 @@
 Library
 -------
 
-- Remove the compiler package.  Use of the _ast module and (an eventual) AST ->
-  bytecode mechanism.
+- Remove popen2 module and os.popen* functions.
+
+- Remove the compiler package.  Use of the _ast module and (an eventual)
+  AST -> bytecode mechanism.
 
 - Remove md5 and sha.  Both have been deprecated since Python 2.5.
 

Modified: python/branches/p3yk/Misc/cheatsheet
==============================================================================
--- python/branches/p3yk/Misc/cheatsheet	(original)
+++ python/branches/p3yk/Misc/cheatsheet	Tue May 15 03:03:38 2007
@@ -1919,7 +1919,6 @@
                  Cimplementation exists in built-in module: cPickle).
 pipes            Conversion pipeline templates.
 pkgunil          Utilities for working with Python packages.
-popen2           variations on pipe open.
 poplib           A POP3 client class. Based on the J. Myers POP3 draft.
 posixfile        Extended (posix) file operations.
 posixpath        Common operations on POSIX pathnames.


More information about the Python-3000-checkins mailing list