| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -152,6 +152,13 @@ def test_incorrect_mro_explicit_object(self): | |||
| 152 | 152 | with self.assertRaisesRegex(TypeError, r"\(MRO\) for bases object, Generic"): | |
| 153 | 153 | class My[X](object): ... | |
| 154 | 154 | ||
| 155 | + def test_compile_error_in_type_param_bound(self): | ||
| 156 | + # This should not crash, see gh-145187 | ||
| 157 | + check_syntax_error( | ||
| 158 | + self, | ||
| 159 | + "if True:\n class h[l:{7for*()in 0}]:2" | ||
| 160 | + ) | ||
| 161 | + | ||
| 155 | 162 | ||
| 156 | 163 | class TypeParamsNonlocalTest(unittest.TestCase): | |
| 157 | 164 | def test_nonlocal_disallowed_01(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Fix compiler assertion fail when a type parameter bound contains an invalid | ||
| 2 | + expression in a conditional block. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1244,11 +1244,11 @@ codegen_type_param_bound_or_default(compiler *c, expr_ty e, | |||
| 1244 | 1244 | ADDOP_LOAD_CONST_NEW(c, LOC(e), defaults); | |
| 1245 | 1245 | RETURN_IF_ERROR(codegen_setup_annotations_scope(c, LOC(e), key, name)); | |
| 1246 | 1246 | if (allow_starred && e->kind == Starred_kind) { | |
| 1247 | - VISIT(c, expr, e->v.Starred.value); | ||
| 1248 | - ADDOP_I(c, LOC(e), UNPACK_SEQUENCE, (Py_ssize_t)1); | ||
| 1247 | + VISIT_IN_SCOPE(c, expr, e->v.Starred.value); | ||
| 1248 | + ADDOP_I_IN_SCOPE(c, LOC(e), UNPACK_SEQUENCE, (Py_ssize_t)1); | ||
| 1249 | 1249 | } | |
| 1250 | 1250 | else { | |
| 1251 | - VISIT(c, expr, e); | ||
| 1251 | + VISIT_IN_SCOPE(c, expr, e); | ||
| 1252 | 1252 | } | |
| 1253 | 1253 | ADDOP_IN_SCOPE(c, LOC(e), RETURN_VALUE); | |
| 1254 | 1254 | PyCodeObject *co = _PyCompile_OptimizeAndAssemble(c, 1); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments