PyDocs

Nav

Internet Data Handling

BytesGenerator

email.generator

class · Added in 3.2 (source)
  • BytesGenerator(outfp, mangle_from_=None, maxheaderlen=None, *, policy=None)
Generates a bytes version of a Message object tree.

Functionally identical to the base Generator except that the output is
bytes and not string.  When surrogates were used in the input to encode
bytes, these are decoded back to bytes for output.  If the policy has
cte_type set to 7bit, then the message is transformed such that the
non-ASCII bytes are properly content transfer encoded, using the charset
unknown-8bit.

The outfp object must accept bytes in its write method.
Changed in 3.3, 3.6
  • 3.3: Added the policy keyword.
  • 3.6: The default behavior of the mangle_from_ and maxheaderlen parameters is to follow the policy.
Members of BytesGenerator

c

clone
Clone this generator with the exact same options.

f

flatten
Print the message object tree rooted at msg to the output file specified when the Generator instance was created.

w

write
Encode s using the ASCII codec and the surrogateescape error handler, and pass it to the write method of the outfp passed to the BytesGenerator’s constructor.
0 Examples
No examples for email.generator/BytesGenerator.
See Also
No see-alsos for email.generator/BytesGenerator
0 Notes
No notes for BytesGenerator