[Python-checkins] cpython (3.2): Fix setup.py register failure with invalid rst in description (#13614).

eric.araujo python-checkins at python.org
Sun Dec 9 04:57:26 CET 2012


http://hg.python.org/cpython/rev/99c80e8a721e
changeset:   80771:99c80e8a721e
branch:      3.2
user:        Éric Araujo <aeric at mtlpy.org>
date:        Sat Dec 08 22:41:11 2012 -0500
summary:
  Fix setup.py register failure with invalid rst in description (#13614).

Original patch by Julien Courteau and Pierre Paul Lefebvre.

files:
  Lib/distutils/command/check.py       |   3 +
  Lib/distutils/tests/test_register.py |  34 ++++++++++-----
  Misc/ACKS                            |   2 +
  Misc/NEWS                            |   3 +
  4 files changed, 31 insertions(+), 11 deletions(-)


diff --git a/Lib/distutils/command/check.py b/Lib/distutils/command/check.py
--- a/Lib/distutils/command/check.py
+++ b/Lib/distutils/command/check.py
@@ -23,6 +23,9 @@
 
         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:
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
--- a/Lib/distutils/tests/test_register.py
+++ b/Lib/distutils/tests/test_register.py
@@ -1,5 +1,4 @@
 """Tests for distutils.command.register."""
-import sys
 import os
 import unittest
 import getpass
@@ -10,11 +9,14 @@
 
 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
+
+try:
+    import docutils
+except ImportError:
+    docutils = None
 
 PYPIRC_NOPASSWORD = """\
 [distutils]
@@ -193,6 +195,7 @@
         self.assertEqual(headers['Content-length'], '290')
         self.assertTrue((b'tarek') in req.data)
 
+    @unittest.skipUnless(docutils is not None, 'needs docutils')
     def test_strict(self):
         # testing the script option
         # when on, the register command stops if
@@ -205,13 +208,6 @@
         cmd.strict = 1
         self.assertRaises(DistutilsSetupError, cmd.run)
 
-        # 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é',
@@ -265,6 +261,22 @@
         finally:
             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', 'tarek at ziade.org')
+        register_module.input = inputs
+        self.addCleanup(delattr, register_module, 'input')
+
+        self.assertRaises(DistutilsSetupError, cmd.run)
+
     def test_check_metadata_deprecated(self):
         # makes sure make_metadata is deprecated
         cmd = self._get_cmd()
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -222,6 +222,7 @@
 Scott Cotton
 Greg Couch
 David Cournapeau
+Julien Courteau
 Steve Cousins
 Alex Coventry
 Matthew Dixon Cowles
@@ -621,6 +622,7 @@
 Christopher Lee
 Tennessee Leeuwenburg
 Luc Lefebvre
+Pierre Paul Lefebvre
 Glyph Lefkowitz
 Vincent Legoll
 Kip Lehman
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -177,6 +177,9 @@
 
 - Issue #16628: Fix a memory leak in ctypes.resize().
 
+- Issue #13614: Fix setup.py 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list