MCPcopy Index your code
hub / github.com/python/cpython / punycode_decode

Function punycode_decode

Lib/encodings/punycode.py:188–210  ·  view source on GitHub ↗
(text, errors)

Source from the content-addressed store, hash-verified

186 return base
187
188def punycode_decode(text, errors):
189 if isinstance(text, str):
190 text = text.encode("ascii")
191 if isinstance(text, memoryview):
192 text = bytes(text)
193 pos = text.rfind(b"-")
194 if pos == -1:
195 base = ""
196 extended = text.upper()
197 else:
198 try:
199 base = str(text[:pos], "ascii", errors)
200 except UnicodeDecodeError as exc:
201 raise UnicodeDecodeError("ascii", text, exc.start, exc.end,
202 exc.reason) from None
203 extended = text[pos+1:].upper()
204 try:
205 return insertion_sort(base, extended, errors)
206 except UnicodeDecodeError as exc:
207 offset = pos + 1
208 raise UnicodeDecodeError("punycode", text,
209 offset+exc.start, offset+exc.end,
210 exc.reason) from None
211
212### Codec APIs
213

Callers 2

decodeMethod · 0.85
decodeMethod · 0.85

Calls 5

strFunction · 0.85
insertion_sortFunction · 0.85
encodeMethod · 0.45
rfindMethod · 0.45
upperMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…