@@ -74,47 +74,13 @@ base class. The more specific exceptions are:
7474 codepoint appears in a position whose contextual requirements are
7575 not satisfied.
7676
77- Exceptions carry machine-readable attributes so that applications
78- do not need to parse the message: ` code ` is a short, stable identifier
79- for the rule that failed (listed below); and, when the failure can be
80- attributed to a particular character, ` text ` (the label, or domain for
81- UTS #46 processing, being validated), ` codepoint ` (the offending
82- codepoint as an integer) and ` position ` (its 1-based index within
83- ` text ` , as quoted in the message) are set. Each is ` None ` when it does
84- not apply. Message wording is not part of the API and may change.
85-
86- ``` pycon
87- >>> try :
88- ... idna.encode(' Königsgäßchen' )
89- ... except idna.IDNAError as err:
90- ... print (err.code, err.codepoint, err.position, err.text)
91- disallowed_codepoint 75 1 Königsgäßchen
92- ```
93-
94- | ` code ` | Meaning |
95- | ---| ---|
96- | ` input_too_long ` | Input exceeds the library's defensive length limit and was not processed |
97- | ` label_too_long ` | A label exceeds 63 octets |
98- | ` domain_too_long ` | The domain exceeds 253 octets |
99- | ` empty_label ` | A label is empty (e.g. consecutive dots) |
100- | ` empty_domain ` | The domain is empty |
101- | ` not_nfc ` | The label is not in Unicode Normalization Form C |
102- | ` hyphen_3_4 ` | The label has hyphens in the 3rd and 4th positions |
103- | ` hyphen_start_end ` | The label starts or ends with a hyphen |
104- | ` leading_combiner ` | The label starts with a combining mark |
105- | ` disallowed_codepoint ` | A codepoint is DISALLOWED or UNASSIGNED under IDNA 2008 |
106- | ` contextj ` | A CONTEXTJ codepoint (joiner) appears in an invalid context |
107- | ` contexto ` | A CONTEXTO codepoint appears in an invalid context |
108- | ` unknown_codepoint ` | A codepoint next to a joiner is unknown to this Python's Unicode database |
109- | ` bidi_rule_1 ` … ` bidi_rule_6 ` | The corresponding rule of RFC 5893 (the Bidi Rule) is violated |
110- | ` bidi_unknown_direction ` | A codepoint's directionality is unknown to this Python's Unicode database |
111- | ` invalid_alabel ` | An ` xn-- ` label is malformed or is not valid Punycode |
112- | ` non_canonical_alabel ` | An ` xn-- ` label is not the canonical Punycode encoding of its U-label (a "fake A-label") |
113- | ` invalid_ascii ` | Byte input is not ASCII |
114- | ` invalid_utf8 ` | Byte input is not UTF-8 |
115- | ` uts46_disallowed ` | A codepoint is disallowed by the UTS #46 mapping table |
116- | ` uts46_std3 ` | An ASCII character is rejected by the UTS #46 STD3 rules |
117- | ` unsupported_errors ` | The codec was given an ` errors ` handler other than ` strict ` |
77+ Exceptions carry machine-readable attributes so that applications do
78+ not need to parse the message: ` code ` is a short, stable identifier
79+ for the rule that failed (such as ` disallowed_codepoint ` or
80+ ` label_too_long ` ); and, when the failure can be attributed to a
81+ particular character, ` text ` (the label or domain being validated),
82+ ` codepoint ` (the offending codepoint as an integer) and ` position `
83+ are set.
11884
11985
12086## Command-line tool
0 commit comments