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

Function insertion_sort

Lib/encodings/punycode.py:158–186  ·  view source on GitHub ↗

3.2 Insertion sort coding

(base, extended, errors)

Source from the content-addressed store, hash-verified

156
157
158def insertion_sort(base, extended, errors):
159 """3.2 Insertion sort coding"""
160 # This function raises UnicodeDecodeError with position in the extended.
161 # Caller should add the offset.
162 char = 0x80
163 pos = -1
164 bias = 72
165 extpos = 0
166
167 while extpos < len(extended):
168 newpos, delta = decode_generalized_number(extended, extpos,
169 bias, errors)
170 if delta is None:
171 # There was an error in decoding. We can't continue because
172 # synchronization is lost.
173 return base
174 pos += delta+1
175 char += pos // (len(base) + 1)
176 if char > 0x10FFFF:
177 if errors == "strict":
178 raise UnicodeDecodeError(
179 "punycode", extended, pos-1, pos,
180 f"Invalid character U+{char:x}")
181 char = ord('?')
182 pos = pos % (len(base) + 1)
183 base = base[:pos] + chr(char) + base[pos:]
184 bias = adapt(delta, (extpos == 0), len(base))
185 extpos = newpos
186 return base
187
188def punycode_decode(text, errors):
189 if isinstance(text, str):

Callers 1

punycode_decodeFunction · 0.85

Calls 2

adaptFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…