Error in the email module documentation ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adrien Di Mascio

    Error in the email module documentation ?

    Hi all,

    While reading the email module documentation, I found an error in a
    small example given for the as_string() method of the Message class:
    Here is the given code :

    (URL : http://python.org/doc/current/lib/mo...l.Message.html)

    from cStringIO import StringIO
    from email.Generator import Generator
    fp = StringIO()
    g = Generator(mangl e_from_=False, maxheaderlen=60 )
    g.flatten(msg)
    text = fp.getvalue()


    The Generator constructor should take the StingIO instance as first
    argument, am I wrong ?

    Although this is only a small mistake, I think it should always
    be fixed.

    If I've missed something or if this error have already been reported,
    just forget my mail.

    Cheers,

    --
    Adrien Di Mascio
    LOGILAB, Paris (France).
    http://www.logilab.com http://www.logilab.fr http://www.logilab.org


  • Terry Reedy

    #2
    Re: Error in the email module documentation ?


    "Adrien Di Mascio" <Adrien.DiMasci o@logilab.fr> wrote in message
    news:mailman.10 65165607.18026. python-list@python.org ...[color=blue]
    > Hi all,
    >
    > While reading the email module documentation, I found an error in a
    > small example given for the as_string() method of the Message class:
    > Here is the given code :
    >
    > (URL :[/color]
    http://python.org/doc/current/lib/mo...l.Message.html)[color=blue]
    >
    > from cStringIO import StringIO
    > from email.Generator import Generator
    > fp = StringIO()
    > g = Generator(mangl e_from_=False, maxheaderlen=60 )
    > g.flatten(msg)
    > text = fp.getvalue()
    >
    >
    > The Generator constructor should take the StingIO instance as first
    > argument[/color]

    Based on 12.2.3 Generating MIME documents:'''
    class Generator( outfp[, mangle_from_[, maxheaderlen]])
    The constructor for the Generator class takes a file-like object
    called outfp for an argument. outfp must support the write() method
    and be usable as the output file in a Python extended print statement.
    ''',
    yes.
    [color=blue]
    > am I wrong ?[/color]

    No
    [color=blue]
    > Although this is only a small mistake, I think it should always
    > be fixed.[/color]

    Of course, Python docs strive for perfection. I did not find report
    in Python/Doc bugs list so added to SourceForge as bug 817178
    Email.message example missing arg

    Terry J. Reedy


    Comment

    Working...