Skip to content

Commit 41646c4

Browse files
authored
Merge branch 'main' into fix/hashlib/openssl-scrypt-90733
2 parents 2ec9888 + cd3e7ac commit 41646c4

File tree

17 files changed

+104
-118
lines changed

17 files changed

+104
-118
lines changed

Doc/library/codecs.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,15 @@ or with dictionaries as mapping tables. The following table lists the codecs by
10651065
name, together with a few common aliases, and the languages for which the
10661066
encoding is likely used. Neither the list of aliases nor the list of languages
10671067
is meant to be exhaustive. Notice that spelling alternatives that only differ in
1068-
case or use a hyphen instead of an underscore are also valid aliases; therefore,
1069-
e.g. ``'utf-8'`` is a valid alias for the ``'utf_8'`` codec.
1068+
case or use a hyphen instead of an underscore are also valid aliases
1069+
because they are equivalent when normalized by
1070+
:func:`~encodings.normalize_encoding`. For example, ``'utf-8'`` is a valid
1071+
alias for the ``'utf_8'`` codec.
1072+
1073+
.. note::
1074+
1075+
The below table lists the most common aliases, for a complete list
1076+
refer to the source :source:`aliases.py <Lib/encodings/aliases.py>` file.
10701077

10711078
On Windows, ``cpXXX`` codecs are available for all code pages.
10721079
But only codecs listed in the following table are guarantead to exist on

Include/fileutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# define S_IFMT 0170000
1717
#endif
1818
#ifndef S_IFLNK
19-
// Windows doesn't define S_IFLNK, but posixmodule.c maps
19+
// Windows doesn't define S_IFLNK, but fileutils.c maps
2020
// IO_REPARSE_TAG_SYMLINK to S_IFLNK.
2121
# define S_IFLNK 0120000
2222
#endif

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ struct _Py_global_strings {
395395
STRUCT_FOR_ID(deterministic)
396396
STRUCT_FOR_ID(device)
397397
STRUCT_FOR_ID(dict)
398-
STRUCT_FOR_ID(dictcomp)
399398
STRUCT_FOR_ID(difference_update)
400399
STRUCT_FOR_ID(digest)
401400
STRUCT_FOR_ID(digest_size)
@@ -470,7 +469,6 @@ struct _Py_global_strings {
470469
STRUCT_FOR_ID(func)
471470
STRUCT_FOR_ID(future)
472471
STRUCT_FOR_ID(generation)
473-
STRUCT_FOR_ID(genexpr)
474472
STRUCT_FOR_ID(get)
475473
STRUCT_FOR_ID(get_debug)
476474
STRUCT_FOR_ID(get_event_loop)
@@ -546,7 +544,6 @@ struct _Py_global_strings {
546544
STRUCT_FOR_ID(kw2)
547545
STRUCT_FOR_ID(kwdefaults)
548546
STRUCT_FOR_ID(label)
549-
STRUCT_FOR_ID(lambda)
550547
STRUCT_FOR_ID(last)
551548
STRUCT_FOR_ID(last_exc)
552549
STRUCT_FOR_ID(last_node)
@@ -562,7 +559,6 @@ struct _Py_global_strings {
562559
STRUCT_FOR_ID(line)
563560
STRUCT_FOR_ID(line_buffering)
564561
STRUCT_FOR_ID(lineno)
565-
STRUCT_FOR_ID(listcomp)
566562
STRUCT_FOR_ID(little)
567563
STRUCT_FOR_ID(lo)
568564
STRUCT_FOR_ID(locale)
@@ -709,7 +705,6 @@ struct _Py_global_strings {
709705
STRUCT_FOR_ID(server_hostname)
710706
STRUCT_FOR_ID(server_side)
711707
STRUCT_FOR_ID(session)
712-
STRUCT_FOR_ID(setcomp)
713708
STRUCT_FOR_ID(setpgroup)
714709
STRUCT_FOR_ID(setsid)
715710
STRUCT_FOR_ID(setsigdef)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/symtable.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,25 +255,13 @@ def is_local_symbol(ident):
255255
if is_local_symbol(st.name):
256256
match st.type:
257257
case _symtable.TYPE_FUNCTION:
258-
# generators are of type TYPE_FUNCTION with a ".0"
259-
# parameter as a first parameter (which makes them
260-
# distinguishable from a function named 'genexpr')
261-
if st.name == 'genexpr' and '.0' in st.varnames:
262-
continue
263258
d[st.name] = 1
264259
case _symtable.TYPE_TYPE_PARAMETERS:
265260
# Get the function-def block in the annotation
266261
# scope 'st' with the same identifier, if any.
267262
scope_name = st.name
268263
for c in st.children:
269264
if c.name == scope_name and c.type == _symtable.TYPE_FUNCTION:
270-
# A generic generator of type TYPE_FUNCTION
271-
# cannot be a direct child of 'st' (but it
272-
# can be a descendant), e.g.:
273-
#
274-
# class A:
275-
# type genexpr[genexpr] = (x for x in [])
276-
assert scope_name != 'genexpr' or '.0' not in c.varnames
277265
d[scope_name] = 1
278266
break
279267
self.__methods = tuple(d)

Lib/test/string_tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,15 @@ def test_replace(self):
767767
self.checkraises(TypeError, 'hello', 'replace', 42, 'h')
768768
self.checkraises(TypeError, 'hello', 'replace', 'h', 42)
769769

770+
def test_replacement_on_buffer_boundary(self):
771+
# gh-127971: Check we don't read past the end of the buffer when a
772+
# potential match misses on the last character.
773+
any_3_nonblank_codepoints = '!!!'
774+
seven_codepoints = any_3_nonblank_codepoints + ' ' + any_3_nonblank_codepoints
775+
a = (' ' * 243) + seven_codepoints + (' ' * 7)
776+
b = ' ' * 6 + chr(256)
777+
a.replace(seven_codepoints, b)
778+
770779
def test_replace_uses_two_way_maxcount(self):
771780
# Test that maxcount works in _two_way_count in fastsearch.h
772781
A, B = "A"*1000, "B"*1000

Lib/test/test_clinic.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,20 +1277,16 @@ def test_base_invalid_syntax(self):
12771277
os.stat
12781278
invalid syntax: int = 42
12791279
"""
1280-
err = dedent(r"""
1281-
Function 'stat' has an invalid parameter declaration:
1282-
\s+'invalid syntax: int = 42'
1283-
""").strip()
1284-
with self.assertRaisesRegex(ClinicError, err):
1285-
self.parse_function(block)
1280+
err = "Function 'stat' has an invalid parameter declaration: 'invalid syntax: int = 42'"
1281+
self.expect_failure(block, err, lineno=2)
12861282

12871283
def test_param_default_invalid_syntax(self):
12881284
block = """
12891285
module os
12901286
os.stat
12911287
x: int = invalid syntax
12921288
"""
1293-
err = r"Syntax error: 'x = invalid syntax\n'"
1289+
err = "Function 'stat' has an invalid parameter declaration:"
12941290
self.expect_failure(block, err, lineno=2)
12951291

12961292
def test_cloning_nonexistent_function_correctly_fails(self):
@@ -2510,7 +2506,7 @@ def test_cannot_specify_pydefault_without_default(self):
25102506
self.expect_failure(block, err, lineno=1)
25112507

25122508
def test_vararg_cannot_take_default_value(self):
2513-
err = "Vararg can't take a default value!"
2509+
err = "Function 'fn' has an invalid parameter declaration:"
25142510
block = """
25152511
fn
25162512
*args: tuple = None

Lib/test/test_symtable.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,58 @@ def test_symtable_entry_repr(self):
527527
expected = f"<symtable entry top({self.top.get_id()}), line {self.top.get_lineno()}>"
528528
self.assertEqual(repr(self.top._table), expected)
529529

530+
def test_lambda(self):
531+
st = symtable.symtable("lambda x: x", "?", "exec")
532+
self.assertEqual(len(st.get_children()), 1)
533+
st = st.get_children()[0]
534+
self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION)
535+
self.assertEqual(st.get_name(), "<lambda>")
536+
self.assertFalse(st.is_nested())
537+
self.assertEqual(sorted(st.get_identifiers()), ["x"])
538+
self.assertEqual(st.get_children(), [])
539+
540+
def test_nested_lambda(self):
541+
st = symtable.symtable("lambda x: lambda y=x: y", "?", "exec")
542+
self.assertEqual(len(st.get_children()), 1)
543+
st = st.get_children()[0]
544+
self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION)
545+
self.assertEqual(st.get_name(), "<lambda>")
546+
self.assertFalse(st.is_nested())
547+
self.assertEqual(sorted(st.get_identifiers()), ["x"])
548+
self.assertEqual(len(st.get_children()), 1)
549+
st = st.get_children()[0]
550+
self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION)
551+
self.assertEqual(st.get_name(), "<lambda>")
552+
self.assertTrue(st.is_nested())
553+
self.assertEqual(sorted(st.get_identifiers()), ["y"])
554+
self.assertEqual(st.get_children(), [])
555+
556+
def test_genexpr(self):
557+
st = symtable.symtable("(x for x in a)", "?", "exec")
558+
self.assertEqual(len(st.get_children()), 1)
559+
st = st.get_children()[0]
560+
self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION)
561+
self.assertEqual(st.get_name(), "<genexpr>")
562+
self.assertFalse(st.is_nested())
563+
self.assertEqual(sorted(st.get_identifiers()), [".0", "x"])
564+
self.assertEqual(st.get_children(), [])
565+
566+
def test_nested_genexpr(self):
567+
st = symtable.symtable("((y for y in x) for x in a)", "?", "exec")
568+
self.assertEqual(len(st.get_children()), 1)
569+
st = st.get_children()[0]
570+
self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION)
571+
self.assertEqual(st.get_name(), "<genexpr>")
572+
self.assertFalse(st.is_nested())
573+
self.assertEqual(sorted(st.get_identifiers()), [".0", "x"])
574+
self.assertEqual(len(st.get_children()), 1)
575+
st = st.get_children()[0]
576+
self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION)
577+
self.assertEqual(st.get_name(), "<genexpr>")
578+
self.assertTrue(st.is_nested())
579+
self.assertEqual(sorted(st.get_identifiers()), [".0", "y"])
580+
self.assertEqual(st.get_children(), [])
581+
530582

531583
class ComprehensionTests(unittest.TestCase):
532584
def get_identifiers_recursive(self, st, res):

0 commit comments

Comments
 (0)