Skip to content
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

Don't crash on unsupported Python 3.10 match statement #11738

Merged
merged 1 commit into from Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions mypy/fastparse.py
Expand Up @@ -1286,6 +1286,10 @@ def visit_Index(self, n: Index) -> Node:
# cast for mypyc's benefit on Python 3.9
return self.visit(cast(Any, n).value)

def visit_Match(self, n: Any) -> None:
self.fail("Match statement is not supported",
line=n.lineno, column=n.col_offset, blocker=True)


class TypeConverter:
def __init__(self,
Expand Down
2 changes: 2 additions & 0 deletions mypy/test/testcheck.py
Expand Up @@ -104,6 +104,8 @@
typecheck_files.append('check-python38.test')
if sys.version_info >= (3, 9):
typecheck_files.append('check-python39.test')
if sys.version_info >= (3, 10):
typecheck_files.append('check-python310.test')

# Special tests for platforms with case-insensitive filesystems.
if sys.platform in ('darwin', 'win32'):
Expand Down
7 changes: 7 additions & 0 deletions test-data/unit/check-python310.test
@@ -0,0 +1,7 @@
[case testMatchStatementNotSupported]
# flags: --python-version 3.10
match str(): # E: Match statement is not supported
case 'x':
1 + ''
case _:
1 + b''