[issue1923] meaningful whitespace can be lost in rfc822_escape

Stephen Emslie report at bugs.python.org
Thu Jan 24 16:44:01 CET 2008


New submission from Stephen Emslie:

distutils.util.rfc822_escape strips each line of its whitespace before
indenting, but this can mean losing meaningful whitespace, such as in
reStructuredText.


distutils uses rfc822_escape to escape fields in metadata, such as
PKG-INFO. This unfortunately means that you cant use reStructuredText
formatting in your long description (suggested in PEP345), or are
limited to a set that doesn't require indentation (no block quotes, etc.).

for example:

>>> rest = """
... a literal python block::
...     >>> import this
... """
>>> print distutils.util.rfc822_escape(rest)

       a literal python block::
       >>> import this

I would be expecting this to look something like:

       a literal python block::
           >>> import this


It looks like this behavior was intentionally added in  rev 20099, but
that was about 7 years ago - before reStructuredText and eggs. I
wonder if it makes sense to re-think that implementation with this
sort of metadata in mind, assuming this behavior isn't required to be
rfc822 compliant. I think it would certainly be a shame to miss out on
a good thing like proper (renderable) reST in our metadata.

Is distutils being over-cautious in flattening out all whitespace? A
w3c discussion on multiple lines in rfc822 [1] seems to suggest that
whitespace can be 'unfolded' safely, so it seems a shame to be
throwing it away when it can have important meaning.

http://www.w3.org/Protocols/rfc822/3_Lexical.html

----------
components: Library (Lib)
messages: 61633
nosy: stephenemslie
severity: normal
status: open
title: meaningful whitespace can be lost in rfc822_escape
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1923>
__________________________________


More information about the Python-bugs-list mailing list