Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .devcontainer/wasi/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"image": "ghcr.io/python/wasicontainer:latest",
"onCreateCommand": [
// Install common tooling.
"dnf",
"install",
"-y",
// For umask fix below.
"/usr/bin/setfacl"
],
"updateContentCommand": {
// Using the shell for `nproc` usage.
"python": "python3 Tools/wasm/wasi build --quiet -- --with-pydebug -C"
},
"postCreateCommand": {
// https://github.com/orgs/community/discussions/26026
"umask fix: workspace": ["sudo", "setfacl", "-bnR", "."],
"umask fix: /tmp": ["sudo", "setfacl", "-bnR", "/tmp"]
},
"customizations": {
"vscode": {
"extensions": [
// Highlighting for Parser/Python.asdl.
"brettcannon.zephyr-asdl",
// Highlighting for configure.ac.
"maelvalais.autoconf",
// C auto-complete.
"ms-vscode.cpptools",
// Python auto-complete.
"ms-python.python"
],
"settings": {
"C_Cpp.default.compilerPath": "/usr/bin/clang",
"C_Cpp.default.cStandard": "c11",
"C_Cpp.default.defines": [
"CONFIG_64",
"Py_BUILD_CORE"
],
"C_Cpp.default.includePath": [
"${workspaceFolder}/*",
"${workspaceFolder}/Include/**"
],
// https://github.com/microsoft/vscode-cpptools/issues/10732
"C_Cpp.errorSquiggles": "disabled",
"editor.insertSpaces": true,
"editor.rulers": [
80
],
"editor.tabSize": 4,
"editor.trimAutoWhitespace": true,
"files.associations": {
"*.h": "c"
},
"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"python.analysis.diagnosticSeverityOverrides": {
// Complains about shadowing the stdlib w/ the stdlib.
"reportShadowedImports": "none",
// Doesn't like _frozen_importlib.
"reportMissingImports": "none"
},
"python.analysis.extraPaths": [
"Lib"
],
"[restructuredtext]": {
"editor.tabSize": 3
}
}
}
}
}
4 changes: 2 additions & 2 deletions .github/workflows/reusable-wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 60
env:
WASMTIME_VERSION: 22.0.0
WASI_SDK_VERSION: 24
WASMTIME_VERSION: 38.0.2
WASI_SDK_VERSION: 25
WASI_SDK_PATH: /opt/wasi-sdk
CROSS_BUILD_PYTHON: cross-build/build
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
Expand Down
5 changes: 5 additions & 0 deletions Grammar/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ mapping_pattern[pattern_ty]:
CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, items)),
NULL,
EXTRA) }
| invalid_mapping_pattern

items_pattern[asdl_seq*]:
| ','.key_value_pattern+
Expand Down Expand Up @@ -1490,6 +1491,10 @@ invalid_class_pattern:
PyPegen_first_item(a, pattern_ty),
PyPegen_last_item(a, pattern_ty),
"positional patterns follow keyword patterns") }
invalid_mapping_pattern:
| '{' (items_pattern ',')? rest=double_star_pattern ',' items_pattern ','? '}' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
rest,
"double star pattern must be the last (right-most) subpattern in the mapping pattern") }
invalid_class_argument_pattern[asdl_pattern_seq*]:
| [positional_patterns ','] keyword_patterns ',' a=positional_patterns { a }
invalid_if_stmt:
Expand Down
11 changes: 10 additions & 1 deletion Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,16 @@ def testSyntaxErrorOffset(self):
check('[\nfile\nfor str(file)\nin\n[]\n]', 3, 5)
check('[file for\n str(file) in []]', 2, 2)
check("ages = {'Alice'=22, 'Bob'=23}", 1, 9)
check('match ...:\n case {**rest, "key": value}:\n ...', 2, 19)
check(dedent("""\
match ...:
case {**rest1, "after": after}:
...
"""), 2, 11)
check(dedent("""\
match ...:
case {"before": before, **rest2, "after": after}:
...
"""), 2, 29)
check("[a b c d e f]", 1, 2)
check("for x yfff:", 1, 7)
check("f(a for a in b, c)", 1, 3, 1, 15)
Expand Down
26 changes: 19 additions & 7 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,6 @@
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match ...:
... case {**rest, "key": value}:
... ...
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match ...:
... case {**_}:
... ...
Expand Down Expand Up @@ -2240,7 +2234,7 @@
Traceback (most recent call last):
SyntaxError: invalid character '£' (U+00A3)

Invalid pattern matching constructs:
Invalid pattern matching constructs:

>>> match ...:
... case 42 as _:
Expand Down Expand Up @@ -2302,6 +2296,24 @@
Traceback (most recent call last):
SyntaxError: positional patterns follow keyword patterns

>>> match ...:
... case {**double_star, "spam": "eggs"}:
... ...
Traceback (most recent call last):
SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern

>>> match ...:
... case {"foo": 1, **double_star, "spam": "eggs"}:
... ...
Traceback (most recent call last):
SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern

>>> match ...:
... case {"spam": "eggs", "b": {**d, "ham": "bacon"}}:
... ...
Traceback (most recent call last):
SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern

Uses of the star operator which should fail:

A[:*b]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support WASI SDK 25.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Wrong placement of a double-star pattern inside a mapping pattern now throws a specialized syntax error.
Contributed by Bartosz Sławecki in :gh:`140253`.
Loading
Loading