Éric Araujo  committed b10c1c6 Merge

Merge fixes for #13614, #13512 and #7719 from 3.3

  • Participants
  • Parent commits 17e5aca, 10ab746

Comments (0)

Files changed (12)

File Doc/distutils/apiref.rst

    destination of the symlink will be copied.  *update* and *verbose* are the same
    as for :func:`copy_file`.
+   Files in *src* that begin with :file:`.nfs` are skipped (more information on
+   these files is available in answer D2 of the `NFS FAQ page
+   <>`_.
+   .. versionchanged:: 3.3.1
+      NFS files are ignored.
 .. function:: remove_tree(directory[, verbose=0, dry_run=0])

File Doc/library/abc.rst

 The :mod:`abc` module also provides the following decorators:
-.. decorator:: abstractmethod(function)
+.. decorator:: abstractmethod
    A decorator indicating abstract methods.
-.. decorator:: abstractclassmethod(function)
+.. decorator:: abstractclassmethod
    A subclass of the built-in :func:`classmethod`, indicating an abstract
    classmethod. Otherwise it is similar to :func:`abstractmethod`.
        :func:`abstractmethod`, making this decorator redundant.
-.. decorator:: abstractstaticmethod(function)
+.. decorator:: abstractstaticmethod
    A subclass of the built-in :func:`staticmethod`, indicating an abstract
    staticmethod. Otherwise it is similar to :func:`abstractmethod`.

File Doc/library/io.rst

    Note that calling any method (even inquiries) on a closed stream is
    undefined.  Implementations may raise :exc:`ValueError` in this case.
-   :class:`IOBase` (and its subclasses) support the iterator protocol, meaning
+   :class:`IOBase` (and its subclasses) supports the iterator protocol, meaning
    that an :class:`IOBase` object can be iterated over yielding the lines in a
    stream.  Lines are defined slightly differently depending on whether the
    stream is a binary stream (yielding bytes), or a text stream (yielding

File Doc/library/sys.rst

    For other systems, the values are:
    ================ ===========================
-   System           :data:`platform` value
+   System           ``platform`` value
    ================ ===========================
    Linux            ``'linux'``
    Windows          ``'win32'``

File Lib/distutils/command/

         def system_message(self, level, message, *children, **kwargs):
             self.messages.append((level, message, children, kwargs))
+            return nodes.system_message(message, level=level,
+                                        type=self.levels[level],
+                                        *children, **kwargs)
     HAS_DOCUTILS = True
 except Exception:

File Lib/distutils/

 that uses .pypirc in the distutils.command package.
 import os
-import sys
 from configparser import ConfigParser
 from distutils.cmd import Command
     def _store_pypirc(self, username, password):
         """Creates a default .pypirc file."""
         rc = self._get_rc_file()
-        f = open(rc, 'w')
-        try:
+        with os.fdopen(, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
             f.write(DEFAULT_PYPIRC % (username, password))
-        finally:
-            f.close()
-        try:
-            os.chmod(rc, 0o600)
-        except OSError:
-            # should do something better here
-            pass
     def _read_pypirc(self):
         """Reads the .pypirc file."""

File Lib/distutils/

         src_name = os.path.join(src, n)
         dst_name = os.path.join(dst, n)
+        if n.startswith('.nfs'):
+            # skip NFS rename files
+            continue
         if preserve_symlinks and os.path.islink(src_name):
             link_dest = os.readlink(src_name)
             if verbose >= 1:

File Lib/distutils/tests/

         remove_tree(self.root_target, verbose=0)
     def test_copy_tree_verbosity(self):
         mkpath(, verbose=0)
         mkpath(, verbose=0)
         a_file = os.path.join(, 'ok.txt')
-        f = open(a_file, 'w')
-        try:
+        with open(a_file, 'w') as f:
             f.write('some content')
-        finally:
-            f.close()
         wanted = ['copying %s -> %s' % (a_file, self.target2)]
         copy_tree(, self.target2, verbose=1)
         remove_tree(self.root_target, verbose=0)
         remove_tree(self.target2, verbose=0)
+    def test_copy_tree_skips_nfs_temp_files(self):
+        mkpath(, verbose=0)
+        a_file = os.path.join(, 'ok.txt')
+        nfs_file = os.path.join(, '.nfs123abc')
+        for f in a_file, nfs_file:
+            with open(f, 'w') as fh:
+                fh.write('some content')
+        copy_tree(, self.target2)
+        self.assertEqual(os.listdir(self.target2), ['ok.txt'])
+        remove_tree(self.root_target, verbose=0)
+        remove_tree(self.target2, verbose=0)
     def test_ensure_relative(self):
         if os.sep == '/':
             self.assertEqual(ensure_relative('/home/foo'), 'home/foo')

File Lib/distutils/tests/

 """Tests for distutils.command.register."""
-import sys
 import os
 import unittest
 import getpass
 from distutils.command import register as register_module
 from distutils.command.register import register
-from distutils.core import Distribution
 from distutils.errors import DistutilsSetupError
-from distutils.tests import support
-from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
+from distutils.tests.test_config import PyPIRCCommandTestCase
+    import docutils
+except ImportError:
+    docutils = None
         self.assertEqual(headers['Content-length'], '290')
         self.assertTrue((b'tarek') in
+    @unittest.skipUnless(docutils is not None, 'needs docutils')
     def test_strict(self):
         # testing the script option
         # when on, the register command stops if
         cmd.strict = 1
-        # we don't test the reSt feature if docutils
-        # is not installed
-        try:
-            import docutils
-        except ImportError:
-            return
         # metadata are OK but long_description is broken
         metadata = {'url': 'xxx', 'author': 'xxx',
                     'author_email': 'éxéxé',
             del register_module.input
+    @unittest.skipUnless(docutils is not None, 'needs docutils')
+    def test_register_invalid_long_description(self):
+        description = ':funkie:`str`'  # mimic Sphinx-specific markup
+        metadata = {'url': 'xxx', 'author': 'xxx',
+                    'author_email': 'xxx',
+                    'name': 'xxx', 'version': 'xxx',
+                    'long_description': description}
+        cmd = self._get_cmd(metadata)
+        cmd.ensure_finalized()
+        cmd.strict = True
+        inputs = Inputs('2', 'tarek', '')
+        register_module.input = inputs
+        self.addCleanup(delattr, register_module, 'input')
+        self.assertRaises(DistutilsSetupError,
     def test_check_metadata_deprecated(self):
         # makes sure make_metadata is deprecated
         cmd = self._get_cmd()

File Lib/distutils/tests/

     @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
     def test_prune_file_list(self):
-        # this test creates a package with some vcs dirs in it
-        # and launch sdist to make sure they get pruned
-        # on all systems
+        # this test creates a project with some VCS dirs and an NFS rename
+        # file, then launches sdist to check they get pruned on all systems
         # creating VCS directories with some files in them
         os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
         self.write_file((self.tmp_dir, 'somecode', '.git',
                          'ok'), 'xxx')
+        self.write_file((self.tmp_dir, 'somecode', '.nfs0001'), 'xxx')
         # now building a sdist
         dist, cmd = self.get_cmd()
 Scott Cotton
 Greg Couch
 David Cournapeau
+Julien Courteau
 Steve Cousins
 Alex Coventry
 Matthew Dixon Cowles
 Drew Jenkins
 Flemming Kjær Jensen
 Philip H. Jensen
+Philip Jenvey
 MunSic Jeong
 Chris Jerdonek
 Jim Jewett
 Thomas Lee
 Tennessee Leeuwenburg
 Luc Lefebvre
+Pierre Paul Lefebvre
 Glyph Lefkowitz
 Vincent Legoll
 Kip Lehman
 - Issue #16628: Fix a memory leak in ctypes.resize().
+- Issue #13614: Fix register failure with invalid rst in description.
+  Patch by Julien Courteau and Pierre Paul Lefebvre.
+- Issue #13512: Create ~/.pypirc securely (CVE-2011-4944).  Initial patch by
+  Philip Jenvey, tested by Mageia and Debian.
+- Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking later
+  on.  Initial patch by SilentGhost and Jeff Ramnani.
 - Issue #13120: Allow to call pdb.set_trace() from thread.
   Patch by Ilya Sandler.