From 9b5235b62ed85e4757f1530cd73ef8d318be6215 Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Wed, 20 Aug 2025 13:07:32 +0200 Subject: [PATCH 1/5] Fix typo in `logging` docs (GH-137981) --- Doc/library/logging.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index e37683e32d01f4..b3017c1ec70032 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -1137,7 +1137,7 @@ Thread Safety ------------- The logging module is intended to be thread-safe without any special work -needing to be done by its clients. It achieves this though using threading +needing to be done by its clients. It achieves this through using threading locks; there is one lock to serialize access to the module's shared data, and each handler also creates a lock to serialize access to its underlying I/O. From 23adbf53c5b1d614c326c27bdc379ff6a775e8fe Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 20 Aug 2025 15:05:38 +0300 Subject: [PATCH 2/5] gh-137044: To weaken the statement regarding the RLIM_INFINITY value (GH-137954) --- Doc/library/resource.rst | 1 - .../2025-08-07-12-32-23.gh-issue-137044.abNoIy.rst | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst index 230f11474f767d..5bc68fdeff4dd2 100644 --- a/Doc/library/resource.rst +++ b/Doc/library/resource.rst @@ -50,7 +50,6 @@ this module for those platforms. .. data:: RLIM_INFINITY Constant used to represent the limit for an unlimited resource. - Its value is larger than any limited resource value. .. versionchanged:: next It is now always positive. diff --git a/Misc/NEWS.d/next/Library/2025-08-07-12-32-23.gh-issue-137044.abNoIy.rst b/Misc/NEWS.d/next/Library/2025-08-07-12-32-23.gh-issue-137044.abNoIy.rst index 4bbf3075dfcafe..5a87d3c7dd04ec 100644 --- a/Misc/NEWS.d/next/Library/2025-08-07-12-32-23.gh-issue-137044.abNoIy.rst +++ b/Misc/NEWS.d/next/Library/2025-08-07-12-32-23.gh-issue-137044.abNoIy.rst @@ -1,4 +1,4 @@ -:data:`resource.RLIM_INFINITY` is now always a positive integer larger than -any limited resource value. This simplifies comparison of the resource -values. Previously, it could be negative, such as -1 or -3, depending on -platform. +:data:`resource.RLIM_INFINITY` is now always a positive integer. +On all supported platforms, it is larger than any limited resource value, +which simplifies comparison of the resource values. +Previously, it could be negative, such as -1 or -3, depending on platform. From 7685b8ada84822a7ee9ce51e8ee0e2e35fd60b4e Mon Sep 17 00:00:00 2001 From: Tangyuan <47830915@qq.com> Date: Wed, 20 Aug 2025 21:08:45 +0800 Subject: [PATCH 3/5] gh-137900: Improve dataclasses frozen parameter documentation (#137937) --- Doc/library/dataclasses.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 299c8aa399c25c..2e4520c823bf3e 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -161,9 +161,11 @@ Module contents :class:`object`, this means it will fall back to id-based hashing). - *frozen*: If true (the default is ``False``), assigning to fields will - generate an exception. This emulates read-only frozen instances. If - :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class, then - :exc:`TypeError` is raised. See the discussion below. + generate an exception. This emulates read-only frozen instances. + See the :ref:`discussion ` below. + + If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class + and *frozen* is true, then :exc:`TypeError` is raised. - *match_args*: If true (the default is ``True``), the :attr:`~object.__match_args__` tuple will be created from the list of From eae9d7de1c45a64076a926d53672823e6ae1777d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 20 Aug 2025 16:18:08 +0300 Subject: [PATCH 4/5] gh-137477: Fix inspect.getblock() for generator expressions (GH-137488) This fixes also inspect.getsourcelines() and inspect.getsource(). --- Lib/inspect.py | 17 +++++++++------- Lib/test/test_inspect/inspect_fodder2.py | 20 +++++++++++++++++++ Lib/test/test_inspect/test_inspect.py | 6 ++++++ ...-08-06-23-16-42.gh-issue-137477.bk6BDV.rst | 2 ++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-08-06-23-16-42.gh-issue-137477.bk6BDV.rst diff --git a/Lib/inspect.py b/Lib/inspect.py index d7814bfeb2b885..f10401e8853317 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1056,7 +1056,7 @@ class BlockFinder: """Provide a tokeneater() method to detect the end of a code block.""" def __init__(self): self.indent = 0 - self.islambda = False + self.singleline = False self.started = False self.passline = False self.indecorator = False @@ -1065,19 +1065,22 @@ def __init__(self): def tokeneater(self, type, token, srowcol, erowcol, line): if not self.started and not self.indecorator: + if type == tokenize.INDENT or token == "async": + pass # skip any decorators - if token == "@": + elif token == "@": self.indecorator = True - # look for the first "def", "class" or "lambda" - elif token in ("def", "class", "lambda"): - if token == "lambda": - self.islambda = True + else: + # For "def" and "class" scan to the end of the block. + # For "lambda" and generator expression scan to + # the end of the logical line. + self.singleline = token not in ("def", "class") self.started = True self.passline = True # skip to the end of the line elif type == tokenize.NEWLINE: self.passline = False # stop skipping when a NEWLINE is seen self.last = srowcol[0] - if self.islambda: # lambdas always end at the first NEWLINE + if self.singleline: raise EndOfBlock # hitting a NEWLINE when in a decorator without args # ends the decorator diff --git a/Lib/test/test_inspect/inspect_fodder2.py b/Lib/test/test_inspect/inspect_fodder2.py index 43fda6622537fc..1de283f672d362 100644 --- a/Lib/test/test_inspect/inspect_fodder2.py +++ b/Lib/test/test_inspect/inspect_fodder2.py @@ -369,3 +369,23 @@ class dc364: # line 369 dc370 = dataclasses.make_dataclass('dc370', (('x', int), ('y', int))) dc371 = dataclasses.make_dataclass('dc370', (('x', int), ('y', int)), module=__name__) + +import inspect +import itertools + +# line 376 +ge377 = ( + inspect.currentframe() + for i in itertools.count() +) + +# line 382 +def func383(): + # line 384 + ge385 = ( + inspect.currentframe() + for i in itertools.count() + ) + return ge385 + +pass # end of file diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py index c8c1a5226114b9..8de2be07aa040d 100644 --- a/Lib/test/test_inspect/test_inspect.py +++ b/Lib/test/test_inspect/test_inspect.py @@ -1189,12 +1189,18 @@ def test_nested_class_definition_inside_async_function(self): self.assertSourceEqual(run(mod2.func225), 226, 227) self.assertSourceEqual(mod2.cls226, 231, 235) + self.assertSourceEqual(mod2.cls226.func232, 232, 235) self.assertSourceEqual(run(mod2.cls226().func232), 233, 234) def test_class_definition_same_name_diff_methods(self): self.assertSourceEqual(mod2.cls296, 296, 298) self.assertSourceEqual(mod2.cls310, 310, 312) + def test_generator_expression(self): + self.assertSourceEqual(next(mod2.ge377), 377, 380) + self.assertSourceEqual(next(mod2.func383()), 385, 388) + + class TestNoEOL(GetSourceBase): def setUp(self): self.tempdir = TESTFN + '_dir' diff --git a/Misc/NEWS.d/next/Library/2025-08-06-23-16-42.gh-issue-137477.bk6BDV.rst b/Misc/NEWS.d/next/Library/2025-08-06-23-16-42.gh-issue-137477.bk6BDV.rst new file mode 100644 index 00000000000000..a6e097ea026293 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-08-06-23-16-42.gh-issue-137477.bk6BDV.rst @@ -0,0 +1,2 @@ +Fix :func:`!inspect.getblock`, :func:`inspect.getsourcelines` and +:func:`inspect.getsource` for generator expressions. From 7fda8b66debb24e0520b94c3769b648c7305f84e Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 20 Aug 2025 22:53:54 +0800 Subject: [PATCH 5/5] gh-137728 gh-137762: Fix bugs in the JIT with many local variables (GH-137764) --- .../2025-08-14-14-18-29.gh-issue-137728.HdYS9R.rst | 1 + Python/optimizer_analysis.c | 5 +---- Python/optimizer_symbols.c | 7 +++++++ 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-08-14-14-18-29.gh-issue-137728.HdYS9R.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-08-14-14-18-29.gh-issue-137728.HdYS9R.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-08-14-14-18-29.gh-issue-137728.HdYS9R.rst new file mode 100644 index 00000000000000..cc4a55ddf383ec --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-08-14-14-18-29.gh-issue-137728.HdYS9R.rst @@ -0,0 +1 @@ +Fix the JIT's handling of many local variables. This previously caused a segfault. diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index dd3e49b83d9971..533d70580e4cc0 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -484,13 +484,10 @@ optimize_uops( _Py_uop_abstractcontext_init(ctx); _Py_UOpsAbstractFrame *frame = _Py_uop_frame_new(ctx, co, curr_stacklen, NULL, 0); if (frame == NULL) { - return -1; + return 0; } ctx->curr_frame_depth++; ctx->frame = frame; - ctx->done = false; - ctx->out_of_space = false; - ctx->contradiction = false; _PyUOpInstruction *this_instr = NULL; for (int i = 0; !ctx->done; i++) { diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c index 8a3df236c80626..8169ce9df5aae6 100644 --- a/Python/optimizer_symbols.c +++ b/Python/optimizer_symbols.c @@ -888,6 +888,13 @@ _Py_uop_abstractcontext_init(JitOptContext *ctx) // Frame setup ctx->curr_frame_depth = 0; + + // Ctx signals. + // Note: this must happen before frame_new, as it might override + // the result should frame_new set things to bottom. + ctx->done = false; + ctx->out_of_space = false; + ctx->contradiction = false; } int