Skip to content

Only accept a flat tuple of types in exception handler clauses #1624

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2016
Merged
Changes from all 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
9 changes: 9 additions & 0 deletions mypy/test/data/check-statements.test
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ try:
except (E1, E2): pass
except (E1, object): pass # E: Exception type must be derived from BaseException
except (object, E2): pass # E: Exception type must be derived from BaseException
except (E1, (E2,)): pass # E: Exception type must be derived from BaseException

except (E1, E2): pass
except ((E1, E2)): pass
except (((E1, E2))): pass
[builtins fixtures/exception.py]

[case testExceptWithMultipleTypes2]
Expand Down Expand Up @@ -656,6 +661,10 @@ except exs2 as e2:
a = e2 # type: E1
b = e2 # type: E1_1 # E: Incompatible types in assignment (expression has type "Union[E1_1, E1_2]", variable has type "E1_1")
c = e2 # type: E1_2 # E: Incompatible types in assignment (expression has type "Union[E1_1, E1_2]", variable has type "E1_2")

exs3 = (E1, (E1_1, (E1_2,)))
try: pass
except exs3 as e3: pass # E: Exception type must be derived from BaseException
[builtins fixtures/exception.py]

[case testInvalidTupleValueAsExceptionType]
Expand Down