Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b503c0

Browse files
author
Éric Araujo
committed
Fix setup.py register failure with invalid rst in description (#13614).
Original patch by Julien Courteau and Pierre Paul Lefebvre.
1 parent 9bc9ab5 commit 8b503c0

4 files changed

Lines changed: 31 additions & 11 deletions

File tree

Lib/distutils/command/check.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def __init__(self, source, report_level, halt_level, stream=None,
2323

2424
def system_message(self, level, message, *children, **kwargs):
2525
self.messages.append((level, message, children, kwargs))
26+
return nodes.system_message(message, level=level,
27+
type=self.levels[level],
28+
*children, **kwargs)
2629

2730
HAS_DOCUTILS = True
2831
except Exception:

Lib/distutils/tests/test_register.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Tests for distutils.command.register."""
2-
import sys
32
import os
43
import unittest
54
import getpass
@@ -10,11 +9,14 @@
109

1110
from distutils.command import register as register_module
1211
from distutils.command.register import register
13-
from distutils.core import Distribution
1412
from distutils.errors import DistutilsSetupError
1513

16-
from distutils.tests import support
17-
from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
14+
from distutils.tests.test_config import PyPIRCCommandTestCase
15+
16+
try:
17+
import docutils
18+
except ImportError:
19+
docutils = None
1820

1921
PYPIRC_NOPASSWORD = """\
2022
[distutils]
@@ -193,6 +195,7 @@ def test_password_reset(self):
193195
self.assertEqual(headers['Content-length'], '290')
194196
self.assertTrue((b'tarek') in req.data)
195197

198+
@unittest.skipUnless(docutils is not None, 'needs docutils')
196199
def test_strict(self):
197200
# testing the script option
198201
# when on, the register command stops if
@@ -205,13 +208,6 @@ def test_strict(self):
205208
cmd.strict = 1
206209
self.assertRaises(DistutilsSetupError, cmd.run)
207210

208-
# we don't test the reSt feature if docutils
209-
# is not installed
210-
try:
211-
import docutils
212-
except ImportError:
213-
return
214-
215211
# metadata are OK but long_description is broken
216212
metadata = {'url': 'xxx', 'author': 'xxx',
217213
'author_email': 'éxéxé',
@@ -265,6 +261,22 @@ def test_strict(self):
265261
finally:
266262
del register_module.input
267263

264+
@unittest.skipUnless(docutils is not None, 'needs docutils')
265+
def test_register_invalid_long_description(self):
266+
description = ':funkie:`str`' # mimic Sphinx-specific markup
267+
metadata = {'url': 'xxx', 'author': 'xxx',
268+
'author_email': 'xxx',
269+
'name': 'xxx', 'version': 'xxx',
270+
'long_description': description}
271+
cmd = self._get_cmd(metadata)
272+
cmd.ensure_finalized()
273+
cmd.strict = True
274+
inputs = Inputs('2', 'tarek', '[email protected]')
275+
register_module.input = inputs
276+
self.addCleanup(delattr, register_module, 'input')
277+
278+
self.assertRaises(DistutilsSetupError, cmd.run)
279+
268280
def test_check_metadata_deprecated(self):
269281
# makes sure make_metadata is deprecated
270282
cmd = self._get_cmd()

Misc/ACKS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ David Costanzo
222222
Scott Cotton
223223
Greg Couch
224224
David Cournapeau
225+
Julien Courteau
225226
Steve Cousins
226227
Alex Coventry
227228
Matthew Dixon Cowles
@@ -621,6 +622,7 @@ Thomas Lee
621622
Christopher Lee
622623
Tennessee Leeuwenburg
623624
Luc Lefebvre
625+
Pierre Paul Lefebvre
624626
Glyph Lefkowitz
625627
Vincent Legoll
626628
Kip Lehman

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ Library
177177

178178
- Issue #16628: Fix a memory leak in ctypes.resize().
179179

180+
- Issue #13614: Fix setup.py register failure with invalid rst in description.
181+
Patch by Julien Courteau and Pierre Paul Lefebvre.
182+
180183
- Issue #13512: Create ~/.pypirc securely (CVE-2011-4944). Initial patch by
181184
Philip Jenvey, tested by Mageia and Debian.
182185

0 commit comments

Comments
 (0)