Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow lambdas in except* clauses#18620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
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
3 changes: 2 additions & 1 deletionmypy/semanal.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6134,7 +6134,8 @@ def analyze_comp_for_2(self, expr: GeneratorExpr | DictionaryComprehension) -> N

def visit_lambda_expr(self, expr: LambdaExpr) -> None:
self.analyze_arg_initializers(expr)
self.analyze_function_body(expr)
with self.inside_except_star_block_set(False, entering_loop=False):
self.analyze_function_body(expr)

def visit_conditional_expr(self, expr: ConditionalExpr) -> None:
expr.if_expr.accept(self)
Expand Down
18 changes: 18 additions & 0 deletionstest-data/unit/check-python311.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -260,6 +260,24 @@ def foo():
return # E: "return" not allowed in except* block
[builtins fixtures/exception.pyi]

[case testLambdaInExceptStarBlock]
# flags: --python-version 3.11
def foo():
try:
pass
except* Exception:
x = lambda: 0
return lambda: 0 # E: "return" not allowed in except* block

def loop():
while True:
try:
pass
except* Exception:
x = lambda: 0
return lambda: 0 # E: "return" not allowed in except* block
[builtins fixtures/exception.pyi]

[case testRedefineLocalWithinExceptStarTryClauses]
# flags: --allow-redefinition
def fn_str(_: str) -> int: ...
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp