Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib/encodings/punycode.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def segregate(str):
else:
extended.add(c)
extended = sorted(extended)
return bytes(base), extended
return base.take_bytes(), extended

def selective_len(str, max):
"""Return the length of str, considering only characters below max."""
Expand Down Expand Up @@ -83,7 +83,7 @@ def generate_generalized_integer(N, bias):
t = T(j, bias)
if N < t:
result.append(digits[N])
return bytes(result)
return result.take_bytes()
result.append(digits[t + ((N - t) % (36 - t))])
N = (N - t) // (36 - t)
j += 1
Expand Down Expand Up @@ -112,7 +112,7 @@ def generate_integers(baselen, deltas):
s = generate_generalized_integer(delta, bias)
result.extend(s)
bias = adapt(delta, points==0, baselen+points+1)
return bytes(result)
return result.take_bytes()

def punycode_encode(text):
base, extended = segregate(text)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove data copy from :mod:`codecs` ``punycode`` encoding by using
:meth:`bytearray.take_bytes`.
Loading