]> granicus.if.org Git - python/commitdiff
Issue #18761: Improved cross-references in email documentation.
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 19 Aug 2013 07:03:11 +0000 (10:03 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 19 Aug 2013 07:03:11 +0000 (10:03 +0300)
1  2 
Doc/library/email.message.rst
Doc/library/email.policy.rst

index 7a74220a3ecad8a47a7ff3fffe5ef22fb87a71bb,576531d0475c794de27d7c1725f82bc4959568c3..4a34c3683c077ebf944cd3709b2e57aa9eb2a170
@@@ -82,47 -68,7 +82,48 @@@ Here are the methods of the :class:`Mes
  
     .. method:: __str__()
  
 -      Equivalent to ``as_string(unixfrom=True)``.
 +      Equivalent to :meth:`.as_string()`.  Allows ``str(msg)`` to produce a
 +      string containing the formatted message.
 +
 +
 +   .. method:: as_bytes(unixfrom=False, policy=None)
 +
 +      Return the entire message flattened as a bytes object.  When optional
 +      *unixfrom* is true, the envelope header is included in the returned
 +      string.  *unixfrom* defaults to ``False``.  The *policy* argument may be
 +      used to override the default policy obtained from the message instance.
 +      This can be used to control some of the formatting produced by the
 +      method, since the specified *policy* will be passed to the
 +      ``BytesGenerator``.
 +
 +      Flattening the message may trigger changes to the :class:`Message` if
 +      defaults need to be filled in to complete the transformation to a string
 +      (for example, MIME boundaries may be generated or modified).
 +
 +      Note that this method is provided as a convenience and may not always
 +      format the message the way you want.  For example, by default it does
 +      not do the mangling of lines that begin with ``From`` that is
 +      required by the unix mbox format.  For more flexibility, instantiate a
 +      :class:`~email.generator.BytesGenerator` instance and use its
-       :meth:`flatten` method directly.  For example::
++      :meth:`~email.generator.BytesGenerator.flatten` method directly.
++      For example::
 +
 +         from io import BytesIO
 +         from email.generator import BytesGenerator
 +         fp = BytesIO()
 +         g = BytesGenerator(fp, mangle_from_=True, maxheaderlen=60)
 +         g.flatten(msg)
 +         text = fp.getvalue()
 +
 +      .. versionadded:: 3.4
 +
 +
 +   .. method:: __bytes__()
 +
 +      Equivalent to :meth:`.as_bytes()`.  Allows ``bytes(msg)`` to produce a
 +      bytes object containing the formatted message.
 +
 +      .. versionadded:: 3.4
  
  
     .. method:: is_multipart()
Simple merge