Skip to content

Commit e39652e

Browse files
authored
Merge branch 'main' into docs
2 parents 56595ce + 6f6f48d commit e39652e

File tree

10 files changed

+389
-142
lines changed

10 files changed

+389
-142
lines changed

.github/workflows/mypy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ on:
1313
- "Lib/test/libregrtest/**"
1414
- "Lib/tomllib/**"
1515
- "Misc/mypy/**"
16+
- "Tools/build/compute-changes.py"
1617
- "Tools/build/generate_sbom.py"
18+
- "Tools/build/verify_ensurepip_wheels.py"
19+
- "Tools/build/update_file.py"
1720
- "Tools/cases_generator/**"
1821
- "Tools/clinic/**"
1922
- "Tools/jit/**"

Lib/test/test_generated_cases.py

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,189 @@ def test_missing_override_failure(self):
20692069
with self.assertRaisesRegex(AssertionError, "All abstract uops"):
20702070
self.run_cases_test(input, input2, output)
20712071

2072+
def test_validate_uop_input_length_mismatch(self):
2073+
input = """
2074+
op(OP, (arg1 -- out)) {
2075+
SPAM();
2076+
}
2077+
"""
2078+
input2 = """
2079+
op(OP, (arg1, arg2 -- out)) {
2080+
}
2081+
"""
2082+
output = """
2083+
"""
2084+
with self.assertRaisesRegex(SyntaxError,
2085+
"Must have the same number of inputs"):
2086+
self.run_cases_test(input, input2, output)
2087+
2088+
def test_validate_uop_output_length_mismatch(self):
2089+
input = """
2090+
op(OP, (arg1 -- out)) {
2091+
SPAM();
2092+
}
2093+
"""
2094+
input2 = """
2095+
op(OP, (arg1 -- out1, out2)) {
2096+
}
2097+
"""
2098+
output = """
2099+
"""
2100+
with self.assertRaisesRegex(SyntaxError,
2101+
"Must have the same number of outputs"):
2102+
self.run_cases_test(input, input2, output)
2103+
2104+
def test_validate_uop_input_name_mismatch(self):
2105+
input = """
2106+
op(OP, (foo -- out)) {
2107+
SPAM();
2108+
}
2109+
"""
2110+
input2 = """
2111+
op(OP, (bar -- out)) {
2112+
}
2113+
"""
2114+
output = """
2115+
"""
2116+
with self.assertRaisesRegex(SyntaxError,
2117+
"Inputs must have equal names"):
2118+
self.run_cases_test(input, input2, output)
2119+
2120+
def test_validate_uop_output_name_mismatch(self):
2121+
input = """
2122+
op(OP, (arg1 -- foo)) {
2123+
SPAM();
2124+
}
2125+
"""
2126+
input2 = """
2127+
op(OP, (arg1 -- bar)) {
2128+
}
2129+
"""
2130+
output = """
2131+
"""
2132+
with self.assertRaisesRegex(SyntaxError,
2133+
"Outputs must have equal names"):
2134+
self.run_cases_test(input, input2, output)
2135+
2136+
def test_validate_uop_unused_input(self):
2137+
input = """
2138+
op(OP, (unused -- )) {
2139+
}
2140+
"""
2141+
input2 = """
2142+
op(OP, (foo -- )) {
2143+
}
2144+
"""
2145+
output = """
2146+
case OP: {
2147+
stack_pointer += -1;
2148+
assert(WITHIN_STACK_BOUNDS());
2149+
break;
2150+
}
2151+
"""
2152+
self.run_cases_test(input, input2, output)
2153+
2154+
input = """
2155+
op(OP, (foo -- )) {
2156+
}
2157+
"""
2158+
input2 = """
2159+
op(OP, (unused -- )) {
2160+
}
2161+
"""
2162+
output = """
2163+
case OP: {
2164+
stack_pointer += -1;
2165+
assert(WITHIN_STACK_BOUNDS());
2166+
break;
2167+
}
2168+
"""
2169+
self.run_cases_test(input, input2, output)
2170+
2171+
def test_validate_uop_unused_output(self):
2172+
input = """
2173+
op(OP, ( -- unused)) {
2174+
}
2175+
"""
2176+
input2 = """
2177+
op(OP, ( -- foo)) {
2178+
foo = NULL;
2179+
}
2180+
"""
2181+
output = """
2182+
case OP: {
2183+
JitOptSymbol *foo;
2184+
foo = NULL;
2185+
stack_pointer[0] = foo;
2186+
stack_pointer += 1;
2187+
assert(WITHIN_STACK_BOUNDS());
2188+
break;
2189+
}
2190+
"""
2191+
self.run_cases_test(input, input2, output)
2192+
2193+
input = """
2194+
op(OP, ( -- foo)) {
2195+
foo = NULL;
2196+
}
2197+
"""
2198+
input2 = """
2199+
op(OP, ( -- unused)) {
2200+
}
2201+
"""
2202+
output = """
2203+
case OP: {
2204+
stack_pointer += 1;
2205+
assert(WITHIN_STACK_BOUNDS());
2206+
break;
2207+
}
2208+
"""
2209+
self.run_cases_test(input, input2, output)
2210+
2211+
def test_validate_uop_input_size_mismatch(self):
2212+
input = """
2213+
op(OP, (arg1[2] -- )) {
2214+
}
2215+
"""
2216+
input2 = """
2217+
op(OP, (arg1[4] -- )) {
2218+
}
2219+
"""
2220+
output = """
2221+
"""
2222+
with self.assertRaisesRegex(SyntaxError,
2223+
"Inputs must have equal sizes"):
2224+
self.run_cases_test(input, input2, output)
2225+
2226+
def test_validate_uop_output_size_mismatch(self):
2227+
input = """
2228+
op(OP, ( -- out[2])) {
2229+
}
2230+
"""
2231+
input2 = """
2232+
op(OP, ( -- out[4])) {
2233+
}
2234+
"""
2235+
output = """
2236+
"""
2237+
with self.assertRaisesRegex(SyntaxError,
2238+
"Outputs must have equal sizes"):
2239+
self.run_cases_test(input, input2, output)
2240+
2241+
def test_validate_uop_unused_size_mismatch(self):
2242+
input = """
2243+
op(OP, (foo[2] -- )) {
2244+
}
2245+
"""
2246+
input2 = """
2247+
op(OP, (unused[4] -- )) {
2248+
}
2249+
"""
2250+
output = """
2251+
"""
2252+
with self.assertRaisesRegex(SyntaxError,
2253+
"Inputs must have equal sizes"):
2254+
self.run_cases_test(input, input2, output)
20722255

20732256
if __name__ == "__main__":
20742257
unittest.main()

Modules/_zstd/_zstdmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ static int _zstd_exec(PyObject *module) {
826826
// ZstdDecompressor
827827
if (add_type_to_module(module,
828828
"ZstdDecompressor",
829-
&ZstdDecompressor_type_spec,
829+
&zstddecompressor_type_spec,
830830
&mod_state->ZstdDecompressor_type) < 0) {
831831
return -1;
832832
}
@@ -890,9 +890,9 @@ _zstd_free(void *module)
890890

891891
static struct PyModuleDef_Slot _zstd_slots[] = {
892892
{Py_mod_exec, _zstd_exec},
893+
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
893894
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
894-
895-
{0}
895+
{0, NULL},
896896
};
897897

898898
struct PyModuleDef _zstdmodule = {

Modules/_zstd/_zstdmodule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ get_zstd_state_from_type(PyTypeObject *type) {
3232

3333
extern PyType_Spec zstddict_type_spec;
3434
extern PyType_Spec zstdcompressor_type_spec;
35-
extern PyType_Spec ZstdDecompressor_type_spec;
35+
extern PyType_Spec zstddecompressor_type_spec;
3636

3737
struct _zstd_state {
3838
PyObject *empty_bytes;

Modules/_zstd/decompressor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ static PyType_Slot ZstdDecompressor_slots[] = {
883883
{0}
884884
};
885885

886-
PyType_Spec ZstdDecompressor_type_spec = {
886+
PyType_Spec zstddecompressor_type_spec = {
887887
.name = "_zstd.ZstdDecompressor",
888888
.basicsize = sizeof(ZstdDecompressor),
889889
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,

0 commit comments

Comments
 (0)