pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/118160.patch

// or if the outer scope is a class block - if (!is_free_in_any_child(comp, k) && ste->ste_type != ClassBlock - && !ste->ste_can_see_class_scope) { + if (!is_free_in_any_child(comp, k) && ste->ste_type != ClassBlock) { if (PySet_Discard(comp_free, k) < 0) { return 0; } From 1a9b8eda9f4782534ec3930039a2e2633c677a8f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 25 Apr 2024 21:18:31 -0700 Subject: [PATCH 4/6] Do not inline them --- .../2024-04-25-21-18-19.gh-issue-118160.GH5SMc.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-04-25-21-18-19.gh-issue-118160.GH5SMc.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-04-25-21-18-19.gh-issue-118160.GH5SMc.rst b/Misc/NEWS.d/next/Core and Builtins/2024-04-25-21-18-19.gh-issue-118160.GH5SMc.rst new file mode 100644 index 00000000000000..c4e798df5de702 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-04-25-21-18-19.gh-issue-118160.GH5SMc.rst @@ -0,0 +1,3 @@ +:ref:`Annotation scopes ` within classes can now contain +comprehensions. However, such comprehensions are not inlined into their +parent scope at runtime. Patch by Jelle Zijlstra. From 79e9332f87e5f4a051d03eb52e1dae795d9ae18d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 25 Apr 2024 21:19:12 -0700 Subject: [PATCH 5/6] Rename "error_cases" --- Doc/whatsnew/3.13.rst | 4 +++- Lib/test/test_type_params.py | 4 ++-- Python/symtable.c | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index ad107aad5db3bd..0cd8b4784e712c 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -276,7 +276,9 @@ Other Language Changes (Contributed by Pedro Sousa Lacerda in :gh:`66449`.) * :ref:`annotation scope ` within class scopes can now - contain lambdas. (Contributed by Jelle Zijlstra in :gh:`109118`.) + contain lambdas and comprehensions. Comprehensions that are located within + class scopes are not inliked into their parent scope. (Contributed by + Jelle Zijlstra in :gh:`109118` and :gh:`118160`.) New Modules diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index cbb576be8126f2..4b86395ee74f75 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -491,13 +491,13 @@ class C: T = "class" {} """ - error_cases = [ + cases = [ "type Alias[T] = (T for _ in (1,))", "type Alias = (T for _ in (1,))", "type Alias[T] = [T for _ in (1,)]", "type Alias = [T for _ in (1,)]", ] - for case in error_cases: + for case in cases: with self.subTest(case=case): ns = run_code(code.format(case)) alias = ns["C"].Alias diff --git a/Python/symtable.c b/Python/symtable.c index 47a92eb6bf0504..eecd159b2c3f17 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1154,10 +1154,12 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, } } - // we inline all non-generator-expression comprehensions + // we inline all non-generator-expression comprehensions, + // except those in annotation scopes that are nested in classes int inline_comp = entry->ste_comprehension && - !entry->ste_generator; + !entry->ste_generator && + !ste->ste_can_see_class_scope; if (!analyze_child_block(entry, newbound, newfree, newglobal, type_params, new_class_entry, &child_free)) From 9e6ade7446bffa32eb39ac4f7903a2fd3a9d4add Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 26 Apr 2024 16:46:10 -0700 Subject: [PATCH 6/6] Update Doc/whatsnew/3.13.rst Co-authored-by: Carl Meyer --- Doc/whatsnew/3.13.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 0cd8b4784e712c..13252d99de6c68 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -277,7 +277,7 @@ Other Language Changes * :ref:`annotation scope ` within class scopes can now contain lambdas and comprehensions. Comprehensions that are located within - class scopes are not inliked into their parent scope. (Contributed by + class scopes are not inlined into their parent scope. (Contributed by Jelle Zijlstra in :gh:`109118` and :gh:`118160`.) pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy