Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/email/errors.py @ 69:33d812a61356
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 17:55:14 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 69:33d812a61356 |
---|---|
1 # Copyright (C) 2001-2006 Python Software Foundation | |
2 # Author: Barry Warsaw | |
3 # Contact: email-sig@python.org | |
4 | |
5 """email package exception classes.""" | |
6 | |
7 | |
8 class MessageError(Exception): | |
9 """Base class for errors in the email package.""" | |
10 | |
11 | |
12 class MessageParseError(MessageError): | |
13 """Base class for message parsing errors.""" | |
14 | |
15 | |
16 class HeaderParseError(MessageParseError): | |
17 """Error while parsing headers.""" | |
18 | |
19 | |
20 class BoundaryError(MessageParseError): | |
21 """Couldn't find terminating boundary.""" | |
22 | |
23 | |
24 class MultipartConversionError(MessageError, TypeError): | |
25 """Conversion to a multipart is prohibited.""" | |
26 | |
27 | |
28 class CharsetError(MessageError): | |
29 """An illegal charset was given.""" | |
30 | |
31 | |
32 # These are parsing defects which the parser was able to work around. | |
33 class MessageDefect(ValueError): | |
34 """Base class for a message defect.""" | |
35 | |
36 def __init__(self, line=None): | |
37 if line is not None: | |
38 super().__init__(line) | |
39 self.line = line | |
40 | |
41 class NoBoundaryInMultipartDefect(MessageDefect): | |
42 """A message claimed to be a multipart but had no boundary parameter.""" | |
43 | |
44 class StartBoundaryNotFoundDefect(MessageDefect): | |
45 """The claimed start boundary was never found.""" | |
46 | |
47 class CloseBoundaryNotFoundDefect(MessageDefect): | |
48 """A start boundary was found, but not the corresponding close boundary.""" | |
49 | |
50 class FirstHeaderLineIsContinuationDefect(MessageDefect): | |
51 """A message had a continuation line as its first header line.""" | |
52 | |
53 class MisplacedEnvelopeHeaderDefect(MessageDefect): | |
54 """A 'Unix-from' header was found in the middle of a header block.""" | |
55 | |
56 class MissingHeaderBodySeparatorDefect(MessageDefect): | |
57 """Found line with no leading whitespace and no colon before blank line.""" | |
58 # XXX: backward compatibility, just in case (it was never emitted). | |
59 MalformedHeaderDefect = MissingHeaderBodySeparatorDefect | |
60 | |
61 class MultipartInvariantViolationDefect(MessageDefect): | |
62 """A message claimed to be a multipart but no subparts were found.""" | |
63 | |
64 class InvalidMultipartContentTransferEncodingDefect(MessageDefect): | |
65 """An invalid content transfer encoding was set on the multipart itself.""" | |
66 | |
67 class UndecodableBytesDefect(MessageDefect): | |
68 """Header contained bytes that could not be decoded""" | |
69 | |
70 class InvalidBase64PaddingDefect(MessageDefect): | |
71 """base64 encoded sequence had an incorrect length""" | |
72 | |
73 class InvalidBase64CharactersDefect(MessageDefect): | |
74 """base64 encoded sequence had characters not in base64 alphabet""" | |
75 | |
76 class InvalidBase64LengthDefect(MessageDefect): | |
77 """base64 encoded sequence had invalid length (1 mod 4)""" | |
78 | |
79 # These errors are specific to header parsing. | |
80 | |
81 class HeaderDefect(MessageDefect): | |
82 """Base class for a header defect.""" | |
83 | |
84 def __init__(self, *args, **kw): | |
85 super().__init__(*args, **kw) | |
86 | |
87 class InvalidHeaderDefect(HeaderDefect): | |
88 """Header is not valid, message gives details.""" | |
89 | |
90 class HeaderMissingRequiredValue(HeaderDefect): | |
91 """A header that must have a value had none""" | |
92 | |
93 class NonPrintableDefect(HeaderDefect): | |
94 """ASCII characters outside the ascii-printable range found""" | |
95 | |
96 def __init__(self, non_printables): | |
97 super().__init__(non_printables) | |
98 self.non_printables = non_printables | |
99 | |
100 def __str__(self): | |
101 return ("the following ASCII non-printables found in header: " | |
102 "{}".format(self.non_printables)) | |
103 | |
104 class ObsoleteHeaderDefect(HeaderDefect): | |
105 """Header uses syntax declared obsolete by RFC 5322""" | |
106 | |
107 class NonASCIILocalPartDefect(HeaderDefect): | |
108 """local_part contains non-ASCII characters""" | |
109 # This defect only occurs during unicode parsing, not when | |
110 # parsing messages decoded from binary. |