@@ -45,18 +45,12 @@ The following exception classes are defined in the :mod:`email.errors` module:
4545
4646.. exception :: MultipartConversionError()
4747
48- Raised when a payload is added to a :class: `~email.message.Message ` object
49- using :meth: `add_payload `, but the payload is already a scalar and the
50- message's :mailheader: `Content-Type ` main type is not either
51- :mimetype: `multipart ` or missing. :exc: `MultipartConversionError ` multiply
52- inherits from :exc: `MessageError ` and the built-in :exc: `TypeError `.
53-
54- Since :meth: `Message.add_payload ` is deprecated, this exception is rarely
55- raised in practice. However the exception may also be raised if the
56- :meth: `~email.message.Message.attach `
57- method is called on an instance of a class derived from
48+ Raised if the :meth: `~email.message.Message.attach ` method is called
49+ on an instance of a class derived from
5850 :class: `~email.mime.nonmultipart.MIMENonMultipart ` (e.g.
5951 :class: `~email.mime.image.MIMEImage `).
52+ :exc: `MultipartConversionError ` multiply
53+ inherits from :exc: `MessageError ` and the built-in :exc: `TypeError `.
6054
6155
6256.. exception :: HeaderWriteError()
@@ -83,51 +77,72 @@ object would have a defect, but the containing messages would not.
8377
8478All defect classes are subclassed from :class: `email.errors.MessageDefect `.
8579
86- * :class: `NoBoundaryInMultipartDefect ` -- A message claimed to be a multipart,
87- but had no :mimetype: `boundary ` parameter.
80+ .. exception :: NoBoundaryInMultipartDefect
81+
82+ A message claimed to be a multipart, but had no :mimetype: `boundary `
83+ parameter.
84+
85+ .. exception :: StartBoundaryNotFoundDefect
86+
87+ The start boundary claimed in the :mailheader: `Content-Type ` header was
88+ never found.
89+
90+ .. exception :: CloseBoundaryNotFoundDefect
91+
92+ A start boundary was found, but no corresponding close boundary was ever
93+ found.
94+
95+ .. versionadded :: 3.3
96+
97+ .. exception :: FirstHeaderLineIsContinuationDefect
98+
99+ The message had a continuation line as its first header line.
100+
101+ .. exception :: MisplacedEnvelopeHeaderDefect
102+
103+ A "Unix From" header was found in the middle of a header block.
104+
105+ .. exception :: MissingHeaderBodySeparatorDefect
106+
107+ A line was found while parsing headers that had no leading white space but
108+ contained no ':'. Parsing continues assuming that the line represents the
109+ first line of the body.
88110
89- * :class: `StartBoundaryNotFoundDefect ` -- The start boundary claimed in the
90- :mailheader: `Content-Type ` header was never found.
111+ .. versionadded :: 3.3
91112
92- * :class: `CloseBoundaryNotFoundDefect ` -- A start boundary was found, but
93- no corresponding close boundary was ever found.
113+ .. exception :: MalformedHeaderDefect
94114
95- .. versionadded :: 3.3
115+ A header was found that was missing a colon, or was otherwise malformed.
96116
97- * :class: ` FirstHeaderLineIsContinuationDefect ` -- The message had a continuation
98- line as its first header line .
117+ .. deprecated :: 3.3
118+ This defect has not been used for several Python versions .
99119
100- * :class: `MisplacedEnvelopeHeaderDefect ` - A "Unix From" header was found in the
101- middle of a header block.
120+ .. exception :: MultipartInvariantViolationDefect
102121
103- * :class: `MissingHeaderBodySeparatorDefect ` - A line was found while parsing
104- headers that had no leading white space but contained no ':'. Parsing
105- continues assuming that the line represents the first line of the body.
122+ A message claimed to be a :mimetype: `multipart `, but no subparts were found.
123+ Note that when a message has this defect, its
124+ :meth: `~email.message.Message.is_multipart ` method may return ``False ``
125+ even though its content type claims to be :mimetype: `multipart `.
106126
107- .. versionadded :: 3.3
127+ .. exception :: InvalidBase64PaddingDefect
108128
109- * :class: `MalformedHeaderDefect ` -- A header was found that was missing a colon,
110- or was otherwise malformed.
129+ When decoding a block of base64 encoded bytes, the padding was not correct.
130+ Enough padding is added to perform the decode, but the resulting decoded
131+ bytes may be invalid.
111132
112- .. deprecated :: 3.3
113- This defect has not been used for several Python versions.
133+ .. exception :: InvalidBase64CharactersDefect
114134
115- * :class: `MultipartInvariantViolationDefect ` -- A message claimed to be a
116- :mimetype: `multipart `, but no subparts were found. Note that when a message
117- has this defect, its :meth: `~email.message.Message.is_multipart ` method may
118- return ``False `` even though its content type claims to be :mimetype: `multipart `.
135+ When decoding a block of base64 encoded bytes, characters outside the base64
136+ alphabet were encountered. The characters are ignored, but the resulting
137+ decoded bytes may be invalid.
119138
120- * :class: `InvalidBase64PaddingDefect ` -- When decoding a block of base64
121- encoded bytes, the padding was not correct. Enough padding is added to
122- perform the decode, but the resulting decoded bytes may be invalid.
139+ .. exception :: InvalidBase64LengthDefect
123140
124- * :class: ` InvalidBase64CharactersDefect ` -- When decoding a block of base64
125- encoded bytes, characters outside the base64 alphabet were encountered.
126- The characters are ignored, but the resulting decoded bytes may be invalid .
141+ When decoding a block of base64 encoded bytes, the number of non-padding
142+ base64 characters was invalid (1 more than a multiple of 4). The encoded
143+ block was kept as-is .
127144
128- * :class: `InvalidBase64LengthDefect ` -- When decoding a block of base64 encoded
129- bytes, the number of non-padding base64 characters was invalid (1 more than
130- a multiple of 4). The encoded block was kept as-is.
145+ .. exception :: InvalidDateDefect
131146
132- * :class: ` InvalidDateDefect ` -- When decoding an invalid or unparsable date field.
133- The original value is kept as-is.
147+ When decoding an invalid or unparsable date field. The original value is
148+ kept as-is.
0 commit comments