From: Tarek Ziadé Date: Sun, 6 Dec 2009 09:22:40 +0000 (+0000) Subject: Fixed #1923: make sure we don't strip meaningful whitespace in PKG-INFO Description... X-Git-Tag: v2.7a2~212 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f38317d5a5665aef199fd30870d14f3cc48ba9c;p=python Fixed #1923: make sure we don't strip meaningful whitespace in PKG-INFO Description field --- diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py index 573d0b9b4f..8b141ca675 100644 --- a/Lib/distutils/tests/test_dist.py +++ b/Lib/distutils/tests/test_dist.py @@ -6,6 +6,7 @@ import StringIO import sys import unittest import warnings +import textwrap from distutils.dist import Distribution, fix_help_options from distutils.cmd import Command @@ -381,6 +382,21 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, if line.strip() != ''] self.assertTrue(len(output) > 0) + def test_long_description(self): + long_desc = textwrap.dedent("""\ + example:: + We start here + and continue here + and end here.""") + attrs = {"name": "package", + "version": "1.0", + "long_description": long_desc} + + dist = distutils.dist.Distribution(attrs) + meta = self.format_metadata(dist) + meta = meta.replace('\n' + 8 * ' ', '\n') + self.assertTrue(long_desc in meta) + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(DistributionTestCase)) diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index 6bff44f786..b8e4952fee 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -558,8 +558,8 @@ def rfc822_escape(header): """Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. """ - lines = [x.strip() for x in header.split('\n')] - sep = '\n' + 8*' ' + lines = header.split('\n') + sep = '\n' + 8 * ' ' return sep.join(lines) _RE_VERSION = re.compile('(\d+\.\d+(\.\d+)*)') diff --git a/Misc/NEWS b/Misc/NEWS index 400431ddab..abcd23c469 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -507,6 +507,9 @@ Core and Builtins Library ------- +- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is + generated in Distutils. Patch by Stephen Emslie. + - Issue #4120: Drop reference to CRT from manifest when building extensions with msvc9compiler.