MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / decode

Method decode

tools/python-3.11.9-amd64/Lib/encodings/idna.py:182–214  ·  view source on GitHub ↗
(self, input, errors='strict')

Source from the content-addressed store, hash-verified

180 return bytes(result+trailing_dot), len(input)
181
182 def decode(self, input, errors='strict'):
183
184 if errors != 'strict':
185 raise UnicodeError("Unsupported error handling "+errors)
186
187 if not input:
188 return "", 0
189
190 # IDNA allows decoding to operate on Unicode strings, too.
191 if not isinstance(input, bytes):
192 # XXX obviously wrong, see #3232
193 input = bytes(input)
194
195 if ace_prefix not in input:
196 # Fast path
197 try:
198 return input.decode('ascii'), len(input)
199 except UnicodeDecodeError:
200 pass
201
202 labels = input.split(b".")
203
204 if labels and len(labels[-1]) == 0:
205 trailing_dot = '.'
206 del labels[-1]
207 else:
208 trailing_dot = ''
209
210 result = []
211 for label in labels:
212 result.append(ToUnicode(label))
213
214 return ".".join(result)+trailing_dot, len(input)
215
216class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
217 def _buffer_encode(self, input, errors, final):

Callers 15

test_configure_dataMethod · 0.45
test_configure_dataMethod · 0.45
ToUnicodeFunction · 0.45
_ipaddr_infoFunction · 0.45
feedMethod · 0.45
header_encodeFunction · 0.45
encode_7or8bitFunction · 0.45
body_encodeMethod · 0.45
_sanitizeFunction · 0.45
parsebytesMethod · 0.45
decode_headerFunction · 0.45

Calls 4

ToUnicodeFunction · 0.70
splitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by 7

test_configure_dataMethod · 0.36
test_configure_dataMethod · 0.36
test_unencodable_diffMethod · 0.36
binFunction · 0.36
test_frozentableMethod · 0.36
dumpFunction · 0.36