[Spambayes] Re: [Spambayes-checkins] spambayes tokenizer.py,1.31,1.32

Barry A. Warsaw barry@python.org
Mon, 23 Sep 2002 11:35:05 -0400


>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:

    GvR> Let's wait until it's decided that email will be backported
    GvR> to 2.2.2.

Cool.

    >> FWIW, get_type() is broken because when looking only at a
    >> single subpart, you can't know what the default type is (so
    >> can't pass in a proper failobj).  It's only by knowing that a
    >> subpart is inside a multipart/digest for instance, that the
    >> subpart's default type is message/rfc822 instead of text/plain.
    >> The Parser handles this properly when creating the message
    >> structure from a string/file, but then every subpart will
    >> always have a content type, so in that case get_type()'s
    >> failobj would never be used.  Thus the API change.

    GvR> I don't understand the last two sentences.  "The Parser
    GvR> handles this..." -- does that refer to the fixed (in 2.3)
    GvR> Parser or to the old Parser in a certain context?

The new Parser, because it'll make a set_default_type() call when it
finds a subpart inside a multipart/digest.

    GvR> AFAICT the *only* place where the default isn't text/plain is
    GvR> inside multipart/digest, and then it's message/rfc822.  So
    GvR> code that asks whether
    GvR> part.get_type()=='multipart/alternative' is in fact not
    GvR> broken.

That comparison will work.
    
    GvR> Code that asks whether
    GvR> part.get_type('text/plain')=='text/plain' but where it is
    GvR> known that part is either the top-level or inside a
    GvR> multipart/alternative is also safe.

Right.  If you /know/ where the subpart lives in the hierarchy, then
you can pass the right default into failobj.

-Barry