Skip to content

Commit 2a883e1

Browse files
Merge branch 'main' into fix-issue-141938
2 parents 9795804 + fa9519f commit 2a883e1

5 files changed

Lines changed: 12 additions & 4 deletions

File tree

Lib/encodings/punycode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def segregate(str):
1717
else:
1818
extended.add(c)
1919
extended = sorted(extended)
20-
return bytes(base), extended
20+
return base.take_bytes(), extended
2121

2222
def selective_len(str, max):
2323
"""Return the length of str, considering only characters below max."""
@@ -83,7 +83,7 @@ def generate_generalized_integer(N, bias):
8383
t = T(j, bias)
8484
if N < t:
8585
result.append(digits[N])
86-
return bytes(result)
86+
return result.take_bytes()
8787
result.append(digits[t + ((N - t) % (36 - t))])
8888
N = (N - t) // (36 - t)
8989
j += 1
@@ -112,7 +112,7 @@ def generate_integers(baselen, deltas):
112112
s = generate_generalized_integer(delta, bias)
113113
result.extend(s)
114114
bias = adapt(delta, points==0, baselen+points+1)
115-
return bytes(result)
115+
return result.take_bytes()
116116

117117
def punycode_encode(text):
118118
base, extended = segregate(text)

Lib/re/_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
375375
# less significant byte is a bit index in the chunk (just like the
376376
# CHARSET matching).
377377

378-
charmap = bytes(charmap) # should be hashable
378+
charmap = charmap.take_bytes() # should be hashable
379379
comps = {}
380380
mapping = bytearray(256)
381381
block = 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove data copy from :mod:`codecs` ``punycode`` encoding by using
2+
:meth:`bytearray.take_bytes`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove data copy from :mod:`re` compilation of regexes with large charsets
2+
by using :meth:`bytearray.take_bytes`.

Tools/c-analyzer/cpython/_parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ def format_tsv_lines(lines):
114114
('*', './Include/internal/mimalloc'),
115115

116116
('Modules/_decimal/**/*.c', 'Modules/_decimal/libmpdec'),
117+
117118
('Modules/_elementtree.c', 'Modules/expat'),
119+
('Modules/pyexpat.c', 'Modules/expat'),
120+
118121
('Modules/_hacl/*.c', 'Modules/_hacl/include'),
119122
('Modules/_hacl/*.c', 'Modules/_hacl/'),
120123
('Modules/_hacl/*.h', 'Modules/_hacl/include'),
@@ -125,6 +128,7 @@ def format_tsv_lines(lines):
125128
('Modules/sha3module.c', 'Modules/_hacl/include'),
126129
('Modules/blake2module.c', 'Modules/_hacl/include'),
127130
('Modules/hmacmodule.c', 'Modules/_hacl/include'),
131+
128132
('Objects/stringlib/*.h', 'Objects'),
129133

130134
# possible system-installed headers, just in case

0 commit comments

Comments
 (0)