<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>18.1.8. email: Exception and Defect classes — Python v2.6.6 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.6.6',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python v2.6.6 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="Python v2.6.6 documentation" href="../index.html" />
<link rel="up" title="18.1. email — An email and MIME handling package" href="email.html" />
<link rel="next" title="18.1.9. email: Miscellaneous utilities" href="email.util.html" />
<link rel="prev" title="18.1.7. email: Encoders" href="email.encoders.html" />
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
accesskey="M">modules</a> |</li>
<li class="right" >
<a href="email.util.html" title="18.1.9. email: Miscellaneous utilities"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="email.encoders.html" title="18.1.7. email: Encoders"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="netdata.html" >18. Internet Data Handling</a> »</li>
<li><a href="email.html" accesskey="U">18.1. <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">email</span></tt> — An email and MIME handling package</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-email.errors">
<h1>18.1.8. <a title="Package supporting the parsing, manipulating, and generating email messages, including MIME documents." class="reference external" href="email.html#module-email"><tt class="xref docutils literal"><span class="pre">email</span></tt></a>: Exception and Defect classes<a class="headerlink" href="#module-email.errors" title="Permalink to this headline">¶</a></h1>
<p>The following exception classes are defined in the <tt class="xref docutils literal"><span class="pre">email.errors</span></tt> module:</p>
<dl class="exception">
<dt id="email.errors.MessageError">
<em class="property">exception </em><tt class="descclassname">email.errors.</tt><tt class="descname">MessageError</tt><a class="headerlink" href="#email.errors.MessageError" title="Permalink to this definition">¶</a></dt>
<dd>This is the base class for all exceptions that the <a title="Package supporting the parsing, manipulating, and generating email messages, including MIME documents." class="reference external" href="email.html#module-email"><tt class="xref docutils literal"><span class="pre">email</span></tt></a> package can
raise. It is derived from the standard <a title="exceptions.Exception" class="reference external" href="exceptions.html#exceptions.Exception"><tt class="xref docutils literal"><span class="pre">Exception</span></tt></a> class and defines no
additional methods.</dd></dl>
<dl class="exception">
<dt id="email.errors.MessageParseError">
<em class="property">exception </em><tt class="descclassname">email.errors.</tt><tt class="descname">MessageParseError</tt><a class="headerlink" href="#email.errors.MessageParseError" title="Permalink to this definition">¶</a></dt>
<dd>This is the base class for exceptions thrown by the <a title="email.parser.Parser" class="reference external" href="email.parser.html#email.parser.Parser"><tt class="xref docutils literal"><span class="pre">Parser</span></tt></a>
class. It is derived from <a title="email.errors.MessageError" class="reference internal" href="#email.errors.MessageError"><tt class="xref docutils literal"><span class="pre">MessageError</span></tt></a>.</dd></dl>
<dl class="exception">
<dt id="email.errors.HeaderParseError">
<em class="property">exception </em><tt class="descclassname">email.errors.</tt><tt class="descname">HeaderParseError</tt><a class="headerlink" href="#email.errors.HeaderParseError" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised under some error conditions when parsing the <span class="target" id="index-289"></span><a class="reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a> headers of a
message, this class is derived from <a title="email.errors.MessageParseError" class="reference internal" href="#email.errors.MessageParseError"><tt class="xref docutils literal"><span class="pre">MessageParseError</span></tt></a>. It can be raised
from the <tt class="xref docutils literal"><span class="pre">Parser.parse()</span></tt> or <tt class="xref docutils literal"><span class="pre">Parser.parsestr()</span></tt> methods.</p>
<p>Situations where it can be raised include finding an envelope header after the
first <span class="target" id="index-290"></span><a class="reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a> header of the message, finding a continuation line before the
first <span class="target" id="index-291"></span><a class="reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a> header is found, or finding a line in the headers which is
neither a header or a continuation line.</p>
</dd></dl>
<dl class="exception">
<dt id="email.errors.BoundaryError">
<em class="property">exception </em><tt class="descclassname">email.errors.</tt><tt class="descname">BoundaryError</tt><a class="headerlink" href="#email.errors.BoundaryError" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised under some error conditions when parsing the <span class="target" id="index-292"></span><a class="reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a> headers of a
message, this class is derived from <a title="email.errors.MessageParseError" class="reference internal" href="#email.errors.MessageParseError"><tt class="xref docutils literal"><span class="pre">MessageParseError</span></tt></a>. It can be raised
from the <tt class="xref docutils literal"><span class="pre">Parser.parse()</span></tt> or <tt class="xref docutils literal"><span class="pre">Parser.parsestr()</span></tt> methods.</p>
<p>Situations where it can be raised include not being able to find the starting or
terminating boundary in a <em>multipart/*</em> message when strict parsing
is used.</p>
</dd></dl>
<dl class="exception">
<dt id="email.errors.MultipartConversionError">
<em class="property">exception </em><tt class="descclassname">email.errors.</tt><tt class="descname">MultipartConversionError</tt><a class="headerlink" href="#email.errors.MultipartConversionError" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised when a payload is added to a <tt class="xref docutils literal"><span class="pre">Message</span></tt> object using
<tt class="xref docutils literal"><span class="pre">add_payload()</span></tt>, but the payload is already a scalar and the message’s
<em>Content-Type</em> main type is not either <em>multipart</em> or
missing. <a title="email.errors.MultipartConversionError" class="reference internal" href="#email.errors.MultipartConversionError"><tt class="xref docutils literal"><span class="pre">MultipartConversionError</span></tt></a> multiply inherits from
<a title="email.errors.MessageError" class="reference internal" href="#email.errors.MessageError"><tt class="xref docutils literal"><span class="pre">MessageError</span></tt></a> and the built-in <a title="exceptions.TypeError" class="reference external" href="exceptions.html#exceptions.TypeError"><tt class="xref docutils literal"><span class="pre">TypeError</span></tt></a>.</p>
<p>Since <tt class="xref docutils literal"><span class="pre">Message.add_payload()</span></tt> is deprecated, this exception is rarely raised
in practice. However the exception may also be raised if the <tt class="xref docutils literal"><span class="pre">attach()</span></tt>
method is called on an instance of a class derived from
<a title="email.mime.nonmultipart.MIMENonMultipart" class="reference external" href="email.mime.html#email.mime.nonmultipart.MIMENonMultipart"><tt class="xref docutils literal"><span class="pre">MIMENonMultipart</span></tt></a> (e.g.
<a title="email.mime.image.MIMEImage" class="reference external" href="email.mime.html#email.mime.image.MIMEImage"><tt class="xref docutils literal"><span class="pre">MIMEImage</span></tt></a>).</p>
</dd></dl>
<p>Here’s the list of the defects that the <tt class="xref docutils literal"><span class="pre">FeedParser</span></tt>
can find while parsing messages. Note that the defects are added to the message
where the problem was found, so for example, if a message nested inside a
<em>multipart/alternative</em> had a malformed header, that nested message
object would have a defect, but the containing messages would not.</p>
<p>All defect classes are subclassed from <tt class="xref docutils literal"><span class="pre">email.errors.MessageDefect</span></tt>, but
this class is <em>not</em> an exception!</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.4: </span>All the defect classes were added.</p>
<ul class="simple">
<li><tt class="xref docutils literal"><span class="pre">NoBoundaryInMultipartDefect</span></tt> – A message claimed to be a multipart,
but had no <em>boundary</em> parameter.</li>
<li><tt class="xref docutils literal"><span class="pre">StartBoundaryNotFoundDefect</span></tt> – The start boundary claimed in the
<em>Content-Type</em> header was never found.</li>
<li><tt class="xref docutils literal"><span class="pre">FirstHeaderLineIsContinuationDefect</span></tt> – The message had a continuation
line as its first header line.</li>
<li><tt class="xref docutils literal"><span class="pre">MisplacedEnvelopeHeaderDefect</span></tt> - A “Unix From” header was found in the
middle of a header block.</li>
<li><tt class="xref docutils literal"><span class="pre">MalformedHeaderDefect</span></tt> – A header was found that was missing a colon,
or was otherwise malformed.</li>
<li><tt class="xref docutils literal"><span class="pre">MultipartInvariantViolationDefect</span></tt> – A message claimed to be a
<em>multipart</em>, but no subparts were found. Note that when a message has
this defect, its <tt class="xref docutils literal"><span class="pre">is_multipart()</span></tt> method may return false even though its
content type claims to be <em>multipart</em>.</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="email.encoders.html"
title="previous chapter">18.1.7. <tt class="docutils literal docutils literal docutils literal"><span class="pre">email</span></tt>: Encoders</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="email.util.html"
title="next chapter">18.1.9. <tt class="docutils literal"><span class="pre">email</span></tt>: Miscellaneous utilities</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li><a href="../_sources/library/email.errors.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
>modules</a> |</li>
<li class="right" >
<a href="email.util.html" title="18.1.9. email: Miscellaneous utilities"
>next</a> |</li>
<li class="right" >
<a href="email.encoders.html" title="18.1.7. email: Encoders"
>previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="netdata.html" >18. Internet Data Handling</a> »</li>
<li><a href="email.html" >18.1. <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">email</span></tt> — An email and MIME handling package</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation.
<br />
The Python Software Foundation is a non-profit corporation.
<a href="http://www.python.org/psf/donations/">Please donate.</a>
<br />
Last updated on Jul 20, 2011.
<a href="../bugs.html">Found a bug</a>?
<br />
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.6.
</div>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez