From 766e7f150ae93d637824d9b156196d98877504d3 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Wed, 10 Sep 2025 01:08:09 +0100 Subject: [PATCH 1/2] gh-135953: Fix refleak in cache method (#138721) --- Lib/profiling/sampling/stack_collector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/profiling/sampling/stack_collector.py b/Lib/profiling/sampling/stack_collector.py index 9df8111c451de8..25539640b8de40 100644 --- a/Lib/profiling/sampling/stack_collector.py +++ b/Lib/profiling/sampling/stack_collector.py @@ -85,8 +85,9 @@ def export(self, filename): print(f"Flamegraph saved to: {filename}") + @staticmethod @functools.lru_cache(maxsize=None) - def _format_function_name(self, func): + def _format_function_name(func): filename, lineno, funcname = func if len(filename) > 50: From 04c7f362055477efeaf3d539da30a608cdbbdc1e Mon Sep 17 00:00:00 2001 From: Dino Viehland Date: Tue, 9 Sep 2025 18:17:00 -0700 Subject: [PATCH 2/2] =?UTF-8?q?gh-138230:=20Remove=20dead=20code=20in=20co?= =?UTF-8?q?de=20gen=20-=20codegen=5Fcheck=5Fannotation=20is=20only=20calle?= =?UTF-8?q?=E2=80=A6=20(#138228)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove dead code in code gen - codegen_check_annotation is only called if future annotations are enabled, and if future annotations are enabled it does nothing. --- Python/codegen.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/Python/codegen.c b/Python/codegen.c index b0778518b2eeb2..ed172dbc0e292e 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -5414,23 +5414,6 @@ codegen_check_ann_expr(compiler *c, expr_ty e) return SUCCESS; } -static int -codegen_check_annotation(compiler *c, stmt_ty s) -{ - /* Annotations of complex targets does not produce anything - under annotations future */ - if (FUTURE_FEATURES(c) & CO_FUTURE_ANNOTATIONS) { - return SUCCESS; - } - - /* Annotations are only evaluated in a module or class. */ - if (SCOPE_TYPE(c) == COMPILE_SCOPE_MODULE || - SCOPE_TYPE(c) == COMPILE_SCOPE_CLASS) { - return codegen_check_ann_expr(c, s->v.AnnAssign.annotation); - } - return SUCCESS; -} - static int codegen_check_ann_subscr(compiler *c, expr_ty e) { @@ -5524,10 +5507,6 @@ codegen_annassign(compiler *c, stmt_ty s) targ->kind); return ERROR; } - /* Annotation is evaluated last. */ - if (future_annotations && !s->v.AnnAssign.simple && codegen_check_annotation(c, s) < 0) { - return ERROR; - } return SUCCESS; }