Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename "error_cases"
  • Loading branch information
JelleZijlstra committed Apr 26, 2024
commit 79e9332f87e5f4a051d03eb52e1dae795d9ae18d
4 changes: 3 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ Other Language Changes
(Contributed by Pedro Sousa Lacerda in :gh:`66449`.)

* :ref:`annotation scope <annotation-scopes>` 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
Comment thread
JelleZijlstra marked this conversation as resolved.
Outdated
Jelle Zijlstra in :gh:`109118` and :gh:`118160`.)


New Modules
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_type_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down