[Python-checkins] bpo-35345: Remove platform.popen() (GH-10781)

Victor Stinner webhook-mailer at python.org
Thu Nov 29 03:58:24 EST 2018


https://github.com/python/cpython/commit/73104fa1e6a791f7d66c0091ed91f6c396ca0fb2
commit: 73104fa1e6a791f7d66c0091ed91f6c396ca0fb2
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-11-29T09:58:20+01:00
summary:

bpo-35345: Remove platform.popen() (GH-10781)

Remove platform.popen() function, it was deprecated since Python 3.3:
use os.popen() instead.

Rename also the "Removed" section to "API and Feature Removals"
of What's New in Python 3.8.

files:
A Misc/NEWS.d/next/Library/2018-11-29-00-55-33.bpo-35345.vepCSJ.rst
M Doc/library/platform.rst
M Doc/whatsnew/3.8.rst
M Lib/platform.py
M Lib/test/test_platform.py

diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst
index 92691fcbeab4..7ac4b027418e 100644
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -212,20 +212,6 @@ Windows Platform
       only runs on Win32 compatible platforms.
 
 
-Win95/98 specific
-^^^^^^^^^^^^^^^^^
-
-.. function:: popen(cmd, mode='r', bufsize=-1)
-
-   Portable :func:`popen` interface.  Find a working popen implementation
-   preferring :func:`win32pipe.popen`.  On Windows NT, :func:`win32pipe.popen`
-   should work; on Windows 9x it hangs due to bugs in the MS C library.
-
-   .. deprecated:: 3.3
-      This function is obsolete.  Use the :mod:`subprocess` module.  Check
-      especially the :ref:`subprocess-replacements` section.
-
-
 Mac OS Platform
 ---------------
 
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index e5e6d4a59944..5492a90aacec 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -373,8 +373,13 @@ Deprecated
   (Contributed by Serhiy Storchaka in :issue:`33710`.)
 
 
-Removed
-=======
+API and Feature Removals
+========================
+
+The following features and APIs have been removed from Python 3.8:
+
+* The function :func:`platform.popen` has been removed, it was deprecated since
+  Python 3.3: use :func:`os.popen` instead.
 
 * The ``pyvenv`` script has been removed in favor of ``python3.8 -m venv``
   to help eliminate confusion as to what Python interpreter the ``pyvenv``
@@ -414,6 +419,9 @@ Changes in Python behavior
 Changes in the Python API
 -------------------------
 
+* The function :func:`platform.popen` has been removed, it was deprecated since
+  Python 3.3: use :func:`os.popen` instead.
+
 * The :meth:`~tkinter.ttk.Treeview.selection` method of the
   :class:`tkinter.ttk.Treeview` class no longer takes arguments.  Using it with
   arguments for changing the selection was deprecated in Python 3.6.  Use
diff --git a/Lib/platform.py b/Lib/platform.py
index b4d4744dadc7..98ee06f85ef1 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -227,15 +227,6 @@ def libc_ver(executable=sys.executable, lib='', version='', chunksize=16384):
             pos = m.end()
     return lib, version
 
-def popen(cmd, mode='r', bufsize=-1):
-
-    """ Portable popen() interface.
-    """
-    import warnings
-    warnings.warn('use os.popen instead', DeprecationWarning, stacklevel=2)
-    return os.popen(cmd, mode, bufsize)
-
-
 def _norm_version(version, build=''):
 
     """ Normalize the version and build strings and return a single
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index c92da904fc5b..686f454827fd 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -3,9 +3,7 @@
 import subprocess
 import sys
 import sysconfig
-import tempfile
 import unittest
-import warnings
 
 from test import support
 
@@ -316,37 +314,6 @@ def test__comparable_version(self):
         self.assertLess(V('1.13++'), V('5.5.kw'))
         self.assertLess(V('0.960923'), V('2.2beta29'))
 
-    def test_popen(self):
-        mswindows = (sys.platform == "win32")
-
-        if mswindows:
-            command = '"{}" -c "print(\'Hello\')"'.format(sys.executable)
-        else:
-            command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
-        with warnings.catch_warnings():
-            warnings.simplefilter("ignore", DeprecationWarning)
-            with platform.popen(command) as stdout:
-                hello = stdout.read().strip()
-                stdout.close()
-                self.assertEqual(hello, "Hello")
-
-        data = 'plop'
-        if mswindows:
-            command = '"{}" -c "import sys; data=sys.stdin.read(); exit(len(data))"'
-        else:
-            command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'"
-        command = command.format(sys.executable)
-        with warnings.catch_warnings():
-            warnings.simplefilter("ignore", DeprecationWarning)
-            with platform.popen(command, 'w') as stdin:
-                stdout = stdin.write(data)
-                ret = stdin.close()
-                self.assertIsNotNone(ret)
-                if os.name == 'nt':
-                    returncode = ret
-                else:
-                    returncode = ret >> 8
-                self.assertEqual(returncode, len(data))
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/Misc/NEWS.d/next/Library/2018-11-29-00-55-33.bpo-35345.vepCSJ.rst b/Misc/NEWS.d/next/Library/2018-11-29-00-55-33.bpo-35345.vepCSJ.rst
new file mode 100644
index 000000000000..e4d3b52c9ef5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-11-29-00-55-33.bpo-35345.vepCSJ.rst
@@ -0,0 +1,2 @@
+The function `platform.popen` has been removed, it was deprecated since Python
+3.3: use :func:`os.popen` instead.



More information about the Python-checkins mailing list