email.errors: Exception and Defect classes¶
Вихідний код: Lib/email/errors.py
Наступні класи винятків визначено в модулі email.errors:
- exception email.errors.MessageError¶
Це базовий клас для всіх винятків, які може створити пакет
email. Він походить від стандартного класуExceptionі не визначає додаткових методів.
- exception email.errors.MessageParseError¶
Це базовий клас для винятків, викликаних класом
Parser. Він походить відMessageError. Цей клас також використовується внутрішньо аналізатором, який використовуєheaderregistry.
- exception email.errors.HeaderParseError¶
Виникає за деяких умов помилки під час аналізу заголовків RFC 5322 повідомлення, цей клас походить від
MessageParseError. Методset_boundary()викличе цю помилку, якщо під час виклику методу тип вмісту невідомий.Headerможе викликати цю помилку для певних помилок декодування base64, а також коли робиться спроба створити заголовок, який, здається, містить вбудований заголовок (тобто, є те, що має бути рядок продовження, який не має початкових пробілів і виглядає як заголовок).
- exception email.errors.BoundaryError¶
Застарілий і більше не використовується.
- exception email.errors.MultipartConversionError¶
Raised if the
attach()method is called on an instance of a class derived fromMIMENonMultipart(e.g.MIMEImage).MultipartConversionErrormultiply inherits fromMessageErrorand the built-inTypeError.
- exception email.errors.HeaderWriteError¶
Raised when an error occurs when the
generatoroutputs headers.
- exception email.errors.MessageDefect¶
This is the base class for all defects found when parsing email messages. It is derived from
ValueError.
- exception email.errors.HeaderDefect¶
This is the base class for all defects found when parsing email headers. It is derived from
MessageDefect.
Ось список дефектів, які FeedParser може знайти під час аналізу повідомлень. Зауважте, що дефекти додаються до повідомлення, у якому виявлено проблему, тому, наприклад, якщо повідомлення, вкладене в multipart/alternative, мало неправильний заголовок, цей вкладений об’єкт повідомлення мав би дефект, але містив би повідомлення не будуть.
Усі класи дефектів є підкласами email.errors.MessageDefect.
- exception email.errors.NoBoundaryInMultipartDefect¶
A message claimed to be a multipart, but had no boundary parameter.
- exception email.errors.StartBoundaryNotFoundDefect¶
The start boundary claimed in the Content-Type header was never found.
- exception email.errors.CloseBoundaryNotFoundDefect¶
A start boundary was found, but no corresponding close boundary was ever found.
Added in version 3.3.
- exception email.errors.FirstHeaderLineIsContinuationDefect¶
The message had a continuation line as its first header line.
- exception email.errors.MisplacedEnvelopeHeaderDefect¶
A «Unix From» header was found in the middle of a header block.
- exception email.errors.MissingHeaderBodySeparatorDefect¶
A line was found while parsing headers that had no leading white space but contained no „:“. Parsing continues assuming that the line represents the first line of the body.
Added in version 3.3.
- exception email.errors.MalformedHeaderDefect¶
A header was found that was missing a colon, or was otherwise malformed.
Застаріло починаючи з версії 3.3: Цей дефект не використовувався для кількох версій Python.
- exception email.errors.MultipartInvariantViolationDefect¶
A message claimed to be a multipart, but no subparts were found. Note that when a message has this defect, its
is_multipart()method may returnFalseeven though its content type claims to be multipart.
- exception email.errors.InvalidBase64PaddingDefect¶
When decoding a block of base64 encoded bytes, the padding was not correct. Enough padding is added to perform the decode, but the resulting decoded bytes may be invalid.
- exception email.errors.InvalidBase64CharactersDefect¶
When decoding a block of base64 encoded bytes, characters outside the base64 alphabet were encountered. The characters are ignored, but the resulting decoded bytes may be invalid.
- exception email.errors.InvalidBase64LengthDefect¶
When decoding a block of base64 encoded bytes, the number of non-padding base64 characters was invalid (1 more than a multiple of 4). The encoded block was kept as-is.
- exception email.errors.InvalidDateDefect¶
When decoding an invalid or unparsable date field. The original value is kept as-is.