[Python-checkins] r77056 - peps/trunk/pep-0345.txt

R. David Murray rdmurray at bitdance.com
Tue Dec 29 15:30:14 CET 2009


On Fri, 25 Dec 2009 08:29:22 -0500, tarek.ziade <python-checkins at python.org> wrote:

tarek.ziade <python-checkins at python.org> wrote:
> +To support empty lines and lines with indentation with respect to
> +the RFC 822 format, any new line has to be suffixed by 7 spaces
> +followed by a pipe (`|`) char. As a result, the Description field is
> +encoded into a folded field that can be interpreted by RFC822
> +parser [2]_.
> +
>  Example::
>  
[...]
> +    Description: This project provides powerful math functions
> +            |For example, you can use `sum()` to sum numbers:
> +            |
> +            |Example::
> +            |
> +            |    >>> sum(1, 2)
> +            |    3
> +            |
> +
> +This encoding implies that any occurences of ``\n |`` have to be replaced
> +by ``\n`` when the field is unfolded using a RFC822 reader.

Actually, a properly operating RFC[2]822 parser will unfold the header
by removing the CFLF.  So the correct method of restoring the line
breaks would be to replace the seven-spaces-plus-'|' with a \n.
(See RFC2822, section 2.2.3).

Unfortunately, Python's email package's parser is not (currently) an
example of a standards conformant parser in that it does not have a mode
that returns the 'unfolded' header.  So if you are using Python's email
package to parse one of these headers, you would need to access the raw
header data (that has the line ends in it) and replace the seven spaces
plus '|' with the null string to recover your original data.

It is also not clear that you can use the current email package to produce
headers in the format you specify, though that may not be an issue.

--
R. David Murray                                      www.bitdance.com
Business Process Automation - Network/Server Management - Routers/Firewalls


More information about the Python-checkins mailing list